Solved

Applet to Servlet session fails

Posted on 2004-04-23
10
742 Views
Last Modified: 2008-03-10
Hi,
I have a JSP page with an applet in it. The applet talks to a Servlet. The session object that is present in my JSP page is not accessable in my servlet.
How can I get the session object from my JSP page to the Servlet through an Applet?

Thanks
Uma
0
Comment
Question by:umajava
  • 3
  • 3
  • 2
10 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
Comment Utility
You can pass the sessionid to the applet as a parameter:

  <parameter name="sess" value="<%= "" + session.getId() %>"/>

Then, you should be able to put the session into the servlet connection in the applet:

   servletConnection.setRequestProperty( "cookie", sess ) ;

Any good?

Tim
0
 

Author Comment

by:umajava
Comment Utility
what is servletConnection? where should I call this
servletConnection.setRequestProperty( "cookie", sess ) ;

in my applet? How do I get the session in my servlet?
0
 

Author Comment

by:umajava
Comment Utility
one more thing is that, this problem is having only for the first time when I log in. As soon as my session in null, I am redirected to the login page again. If I login again using the same browser, now everything works fine.
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> in my applet?

I guess you create a URLConnection to your servlet (from inside the applet)?

There is where you set the session id

> How do I get the session in my servlet?

  public void doPost( HttpServletRequest req, HttpServletResponse res )
  {
      HttpSession session = req.getSession() ;
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 27

Expert Comment

by:rrz
Comment Utility
To use Tim's idea, maybe you could try
<parameter name="sess" value="<%= "jsessionid=" + session.getId() %>"/>    
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Or maybe add

servletConnection.setRequestProperty( "jsessionid", sess ) ;

as well as

servletConnection.setRequestProperty( "cookie", sess ) ;

Though this isn't necessary in my code...
0
 
LVL 27

Expert Comment

by:rrz
Comment Utility
or just add the jsessionid as extra path info  on the url
0
 

Author Comment

by:umajava
Comment Utility
Tim
I will try this idea and get back to you.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ajax auto save 15 93
logging jar 1 104
SimpleDateFormat.parse examples 19 84
immutable object concept 5 104
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
A procedure for exporting installed hotfix details of remote computers using powershell
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now