File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Getting session object info from another jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Getting session object info from another jsp" Watch "Getting session object info from another jsp" New topic
Author

Getting session object info from another jsp

James Drinkard
Greenhorn

Joined: May 30, 2002
Posts: 19
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

Joined: Jan 10, 2002
Posts: 61772
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61772
    
  67

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting session object info from another jsp