Jump to content

Sesssion Variable Returns Null


Guest shiningstar
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...