• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp session?

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 93
Mac Objective C Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I learned something new!

Thanks.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Hang a left on main. Then read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic