Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp session?

 
Ravinder Rana
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rusty Smythe
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65225
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I learned something new!

Thanks.
 
abhishek gowlikar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic