Jump to content

Sesssion Variable Returns Null


Guest shiningstar

Recommended Posts

Guest shiningstar

Hi all, I am developing a WAP application using jsp. I want to set and retrieve session variables using jsp.

chooseques.jsp <%@ page contentType="text/vnd.wap.wml" %><%@page language="java" import="java.sql.*" %>...session.setAttribute( "sess_count", count );System.out.println("sess_count="+session.getAttribute("sess_count"));// This displays the sess_count correctly %>displayques.jsp<%@ page contentType="text/vnd.wap.wml" %><%@page language="java" import="java.sql.*" %><% ...String count =(String)session.getAttribute("sess_count");//I'm retriving the session variable but it returns null!! %>

I have tried the above codes. Session variable is returning null in the second page. Can anyone tell me where is the problem?

Link to comment
Share on other sites

Hi all, I am developing a WAP application using jsp. I want to set and retrieve session variables using jsp.
chooseques.jsp <%@ page contentType="text/vnd.wap.wml" %><%@page language="java" import="java.sql.*" %>...session.setAttribute( "sess_count", count );System.out.println("sess_count="+session.getAttribute("sess_count"));// This displays the sess_count correctly %>displayques.jsp<%@ page contentType="text/vnd.wap.wml" %><%@page language="java" import="java.sql.*" %><% ...String count =(String)session.getAttribute("sess_count");//I'm retriving the session variable but it returns null!! %>

I have tried the above codes. Session variable is returning null in the second page. Can anyone tell me where is the problem?

Try adding the following attribute:
session="true"

To one of the page directive in both JSPs.It should then look like this:

<%@page language="java" import="java.sql.*" session="true" %>

Hope that helps.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...