Results 1 to 4 of 4
  1. #1
    sengreen is offline Member
    Join Date
    Feb 2015
    Posts
    2
    Rep Power
    0

    Default Getting session in servlet when called by applet

    Hi I am new to this forum. I am developing an application combination of JSP, servlets and applet. There is one JSP page (say 1st) contains a web form to enter a date of month. This page calls another (say 2nd) jsp page which gets the date value and set it in session (say "datesession"). After setting session value 2nd JSP page calls an applet. This applet then internally calls the servlet by URLConnection. Now the servlet has the query that needs form date to get the data from database. when I try to get the date value from session("datesession") that is already set by 2nd jsp page, it returns null. Now I am totally stuck at this point. I also have other way in my mind and that is to set date through applet to servlet and then servlet will get the date. But I did first procedure once, but now I cannot. Some body please help me in this problem. I tried many ways but in vein.

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,983
    Rep Power
    8

    Default Re: Getting session in servlet when called by applet

    1) How does a "JSP call an applet"?

    2) Sessions are usually cookie based. So if you have a URLConnection talking directly to the servlet URL, you don't send the appropriate sessioncookies and thus a new session is created for every call. Here is a nice write up: java - New Session is created between consecutive servlet request from an Applet and a managed bean? - Stack Overflow
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    sengreen is offline Member
    Join Date
    Feb 2015
    Posts
    2
    Rep Power
    0

    Default Re: Getting session in servlet when called by applet

    1) Applet is basically embedded in a JSP page
    2) I am trying to implement this suggested solution. Then I will let you know.
    By the thanks for reply.

  4. #4
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Getting session in servlet when called by applet

    I'm not too familiar with applets, but you can pass values as parameters to them right? I wouldn't want to fiddle with sessions in this way if you can just pass in data directly.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. css file doesn't load in jsp when I called it through servlet RequestDispatcher
    By mohsen.noor in forum JavaServer Pages (JSP) and JSTL
    Replies: 5
    Last Post: 10-28-2014, 02:55 PM
  2. servlet question on session.
    By rupeshkadam in forum Java Servlet
    Replies: 3
    Last Post: 08-08-2014, 03:35 PM
  3. Replies: 1
    Last Post: 12-11-2010, 08:25 PM
  4. session in servlet
    By erakhman in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-14-2010, 05:20 PM
  5. doPost() is not called in servlet logic
    By bubulina in forum Java Servlet
    Replies: 6
    Last Post: 10-28-2009, 10:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •