File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes session problem using Tomcat 3.3.1 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "session problem using Tomcat 3.3.1" Watch "session problem using Tomcat 3.3.1" New topic

session problem using Tomcat 3.3.1

Murugan Manickam

Joined: Jun 04, 2002
Posts: 10
Hi all,
I am facing a critical problem for session tracking. The code is working fine using resin.
but using tomcat 3.3.1, it is not working.
let me explain the scenario.
I have a html file which calls the servlet, and after processing, the servlet redirects the response to a jsp file using sendRedirect() method.
When i retreive the session value using session.getAttribute("xVar") in the jsp, it gives null.
then, i used getServletContext().getRequestDispatcher("url").forward(request,response) in the servlet class instead of sendRedirect(), it gives appropriate value in the jsp.. but, it will not work for other pages(entire session)..
from this i have confirmed that, session variable setting is working..
I tested the same code with IE5.5 and Netscape 4.7, it gives the same error.
I also compared resin.conf file with server.xml,in resin they used enable cookies and URL-Rewriting.
Is there any settings to be done in server.xml to get session variables..
Can anyone please ,help me to resolve this issue..
let me paste the code here..
Thanks in advance..

<head><title>This is the html file</title></head>
<form action="/servlet/SampleServlet" method=GET >
<a href="http://localhost:8080/servlet/SampleServlet" > Click to Servlet </a>
import javax.servlet.*;
import javax.servlet.http.*;
public class SampleServlet extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
HttpSession session = null;
session = req.getSession(true);
session.setAttribute("xSample","This is a sample string");
if (session.getAttribute("xSample") != null){
String sSample = (String) session.getAttribute("xSample");
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
<head><title>Sample JSP [age </title></head>
if (session.getAttribute("xSample")!= null){
String strSample= (String)session.getAttribute("xSample");
out.println("Sample got : "+strSample);
System.out.println("String is null");
The cookies enable attributes in Resin which is not specified in tomcat is
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

**** Check out the handy dandy UBB [CODE] tags, they'll preserve the whitespace in your code when you post it to make it easier to read.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Try this:
Murugan Manickam

Joined: Jun 04, 2002
Posts: 10
I used the default settings for sessionid in server.xml..
Is there any special settings to be done for session id in server.xml
In the tomcat doc, there is no where specified for session id..
Can any one tell me the settings of server.xml for sessionid..
thanks in advance,
I agree. Here's the link:
subject: session problem using Tomcat 3.3.1
It's not a secret anymore!