Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Problem with session tracking

Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble with session tracking in servlet/JSP pages. I have a form in my JSP page the action for which is handled by the servlet MyServlet. Here is the code snippet:
<%@ page session="true" %>
<form name="myForm"
Your Session ID: <%=session.getId() %>
When I open this page in the browser, it prints the session ID. I am trying to access the session object from MyServlet and it is coming out to be null and the following code prints :
"Session is null"
public void doPost(HttpServletRequest request,
HttpServletResponse response )
throws IOException, ServletException {
HttpSession session = request.getSession(false);

if(session == null) {
System.out.println("Session is null");
I don't want to create a new session in the servlet but want to use the HttpSession(session) created by the JSP page.
Any help is greatly appreciated.

[This message has been edited by Vani Kadur (edited May 24, 2001).]
Let me tell you a story about a man named Jed. He made this tiny ad:
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic