Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

jsp:useBean

 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 67415
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
geeta lalchandani
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Farmers know to never drive a tractor near a honey locust tree. But a tiny ad is okay:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic