Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7437343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:23:05+00:00 2026-05-29T10:23:05+00:00

I will appreciate if someone help me with the following problem. I have a

  • 0

I will appreciate if someone help me with the following problem.
I have a jasper report which i fill in a PrintingBean and its all good. The moment I clicked on a print preview button (opening the applet) my app throws a null pointer exception at:

if (bean.getPrintingDataList() != null && !bean.getPrintingDataList().isEmpty())

It seems like it makes new session (but I can’t see that on gui, its all good). My manageBean is a SessionScoped. This is my whole method:

private void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    JasperPrint jasperPrint = null;

    try {
        PrintingBean bean = (PrintingBean) request.getSession().getAttribute("printMB");
        if (bean.getPrintingDataList() != null && !bean.getPrintingDataList().isEmpty()) {
            jasperPrint = printManager.print(bean.getPrintingDataList());
        }
    } catch (Exception ex) {
        Logger.getLogger(JasperPrintServlet.class.getName()).log(Level.SEVERE, null, ex);
    }
    if (jasperPrint != null) {
        response.setContentType("application/octet-stream");
        ServletOutputStream ouputStream = response.getOutputStream();

        ObjectOutputStream oos = new ObjectOutputStream(ouputStream);
        oos.writeObject(jasperPrint);
        oos.flush();
        oos.close();

        ouputStream.flush();
        ouputStream.close();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:23:06+00:00Added an answer on May 29, 2026 at 10:23 am

    The session is maintained by a cookie with the name JSESSIONID. Normally, this cookie is set by the server on start of session and this cookie is returned back from client to server on every subsequent single HTTP request throughout the session. The client (the webbrowser) does this all transparently. See also How do servlets work? Instantiation, sessions, shared variables and multithreading.

    In the applet you need to simulate the same as the webbrowser is doing. When the applet connects to the servlet and needs to access the same session as the page which is serving the applet, then you should make sure that you append the very same session cookie to the HTTP request which is been sent by the applet.

    The easiest is to pass the session ID as a parameter to the applet:

    <param name="JSESSIONID" value="#{session.id}">
    

    (note: I’m assuming that you’re using Facelets as view technology, if you were using JSP, then you should use ${pageContext.session.id} instead)

    So that you can set the needed session cookie in the applet accordingly:

    String jSessionID = getParameter("JSESSIONID");
    URL servletURL = new URL(getCodeBase(), "yourServletURL");
    URLConnection connection = servletURL.openConnection();
    connection.setRequestProperty("Cookie", "JSESSIONID=" + jSessionID);
    // ...
    

    This should give you the same session back in the servlet on request.getSession().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please help me with the following problem: There are two classes MainForm
I will really appreciate help for this. My html v2 file with some temporary
I needed some help/pointers on a homework problem. I would really appreciate it if
following is the problem i am facing. i will explain it will an example
Could someone help me translate the following pseudo-code into code understood by Helicon Tech's
Summary So I have 3 tables, which I have screenshots below. Every user will
Basic question.. had to ask. Any help will be appreciated. Q: Why can't I
Anyone that can help me out will be very much appreciated. I seem to
Will the following two SQL statements always produce the same result set? 1. SELECT
Will I have to pay again? I have about 9 months left before renewal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.