Jump to content
Sign in to follow this  
Guest shiningstar

Sesssion Variable Returns Null

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...