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

jsp session?

Ravinder Rana
Greenhorn

Joined: May 10, 2006
Posts: 29
Hi ranchers,

In my application i'm passing data(database table) from servlet to jsp
through session.

My servlet session code is


And my jsp session code is


guys, i got the jaspr exception in jsp page.i jst want to print the table on the jsp page.

please correct me if i'm wrong,i'm a bit confuse


Any help would be greately appriciated, thanks in advance.

Only those who will risk going too far, can possibly find out how far one can go !!!

[ August 10, 2006: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

guys, i got the jaspr exception in jsp page


Telling us that you got an exception without showing us the exception is less than helpful.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rusty Smythe
Ranch Hand

Joined: Aug 09, 2006
Posts: 93
What is "list"?



You say you are passing a "database table," but it looks like you're passing a string only.

From a memory-resource-management standpoint, you might consider passing this data in the _request_ rather than in the session. Sessions are best used to store state information (user login credentials, for example), not data that is passed between servlet (controller) and jsp (view).
Samuel Lugo
Greenhorn

Joined: Feb 28, 2005
Posts: 24
Hello,

If I'm not mistaken, I believe you need to get the session first:

HttpSession session = request.getSession();
String st = (String) session.getAttribute("Table");

Hope that helps.
Rusty Smythe
Ranch Hand

Joined: Aug 09, 2006
Posts: 93
Originally posted by Samuel Lugo:
If I'm not mistaken, I believe you need to get the session first:
Er, not quite. JSP includes session automatically.

Here is my test.jsp. It will function properly as-is.
[ August 11, 2006: Message edited by: Rusty Smythe ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60997
    
  65

Originally posted by Samuel Lugo:

If I'm not mistaken, I believe you need to get the session first:


You are mistaken.

As Rusty pointed out, session is one of the JSP built-in variables (like request) that is available in the service body of a JSP.
[ August 11, 2006: Message edited by: Bear Bibeault ]
Samuel Lugo
Greenhorn

Joined: Feb 28, 2005
Posts: 24
I learned something new!

Thanks.
abhishek gowlikar
Greenhorn

Joined: Aug 17, 2006
Posts: 13
<%@page import="javax.servlet.http.HttpSession" %>
Here in Jsp session is a Implicit Object you no need to import are create a instance,

simply use:

String x=(string)session.getAttribute("name");

Remove the import javax.servlet.http.HttpSession"
your programme will work fine
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: jsp session?