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 jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp:useBean" Watch "jsp:useBean" New topic
Author

jsp:useBean

geeta lalchandani
Ranch Hand

Joined: Jun 07, 2005
Posts: 118
refering to Head Frst JSP Servlets ,,page 416.




What happens when these parts of servlet code Exceute? (person is abstract and eMployee is concrete).

1
Person p = new Employee();
p.setName("evan");
request.setAttribute("person", p);

2
Employee p = new Employee();
p.setName("evan");
request.setAttribute("person", p);

Should the results of both not be the same?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61103
    
  66

You can find the java servlet that the JSP engine creates on behalf of the JSP and see what happens. If you are using Tomcat, it places these in the folder hierarchy under $CATALINA_HOME/work.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
geeta lalchandani
Ranch Hand

Joined: Jun 07, 2005
Posts: 118
the book specified that the second option wud work..
tested that .. it doesnt.

Bear, why do you want me to look at the servlet code? The query was for the useBean.. anything specific you wanted to point to
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by geetu lalchandani:
the book specified that the second option wud work..
tested that .. it doesnt.


Can you explain what you mean by "it doesn't"?
Was an exception thrown? If so, can you post the stack trace?
What behviour were you expecting?
What actually happened.

I don't see anyting wrong with either example.

Originally posted by geetu lalchandani:

Bear, why do you want me to look at the servlet code? The query was for the useBean.. anything specific you wanted to point to


I think Bear's statement was more general.
Anytime you want to find out how the JSP compiler is dealing with a particular piece of code, the first place you should look is in the generated servlet code.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp:useBean