aspose file tools*
The moose likes Servlets and the fly likes HttpSession failure Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSession failure" Watch "HttpSession failure" New topic
Author

HttpSession failure

N SRao
Greenhorn

Joined: Nov 13, 2001
Posts: 11
Hi
I am geting problem with the session in servlet.I am using the jswdk 1.0.1 as webserver. I am chaining 4 servlets one by one and passing the session variable from one servlet to other servlet. But when I tried to access the session variable from the next servlets, getting the session variable as null.
I am using the session objects as follows in all the 4 servlets.
No where I used session invalidate or timeout methods.
HttpSession httpSession = req.getSession(true);
session.getValue(arg);
session.putValue(arg);
her I am sending entire code.

public class MailServlet extends HttpServlet
{
private ObjectInputStream is;
private ObjectInputStream is;
Vector v_fwdMail= new Vector();
Vector v_fileName,v_mailFiles,v_attachFile;
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException
{
Vector v_messageData;
String name="",comment="";
v_messageData=new Vector();
v_attachFile=new Vector();
Vector v_fwdAttach = new Vector();
try
{
System.out.println("Before Sesion");
HttpSession httpSession = req.getSession(true);

is=new ObjectInputStream(req.getInputStream());
System.out.println("Before Sesion 1");
v_messageData=(Vector)is.readObject();
name=(String)v_messageData.elementAt(0);
System.out.println("Name : "+name);
comment=(String)v_messageData.elementAt(1);
httpSession.putValue("com",comment);
System.out.println(" my comment are here "+comment);
v_attachFile=(Vector)v_messageData.elementAt(2);
//httpSession.putValue("subject",subject);
System.out.println(" Vector size is " + v_attachFile.size());
httpSession.putValue("fwdMailFile",v_fwdAttach);
writeData(res);
}

catch(Exception e)
{
System.out.println("Error in getting Names from request : "+e.getMessage());
}
}
public void writeData(HttpServletResponse res)
{
String url="";
url = "http://192.168.1.122:8080/servlet/ThirdServlet?login=yes";


try
{
//Code for serializing the data from Livelink
ObjectOutputStream os = new ObjectOutputStream(res.getOutputStream());
os.writeObject(url);
os.flush();
os.close();
System.out.println("Object written");
}
catch(Exception e)
{
System.out.println("Error in Serializing: "+e.getMessage());
}

}
}
thanks
hari
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: HttpSession failure