Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting session object info from another jsp

 
James Drinkard
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have some customer data that I populate into a customer object and then pass that information into the session in a servlet. I import the package for that class and then reference the name I used to put the information into the session and then have some servlet methods pull the info to a jsp page. However, when I try to retieve the info from another jsp page I'm doing something wrong!
This is in the first jsp page:
<%@ page import="com.Customer"%>
<% Customer cust = null;
try{
cust = (Customer) session.getAttribute("customer"); }
catch etc...
%>
and here an example of a method: <%=cust.getCustEmail()%>
You get to the second jsp page by a relative link and on the second jsp page I'm not sure what I do to get that customer object instantiated again to use that same method?
Thanks for any help,
James
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch jEston!
You'll find this forum a great place to seek help on JSP pages, and there aren't many rules you'll have to worry about, but one is that proper names are required. Please take a look at the JavaRanch Naming Policy and change your display name to match it.
Thanks!
bear
JSP Forum Bartender
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As to your question, you are correct in that anything placed onto the session in an attribute should be available to all JSP pages and servlets that are participating in that session.
I didn't see anything inherently wrong with your code to pluck the attribute from the session, but you didn't show the code you are using to originally set the attribute into the session. Could we take a look at that?
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic