Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Name was not previously introduced as per JSP.5.3  RSS feed

 
Jay Josh
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All !!! I am doing a small project by using JSP standard action elements.

Employee.java (bean)



Login.jsp


StdAct.jsp


Above after setting Employee bean properties I am forwarding it to FinalJsp.jsp page where I want to display bean properties.

FinalJsp.jsp


web.xml



After submitting data through Login.jsp page I am getting the following error



However when I am using <jsp:getProperty> elements on the same page i.e. StdAct.jsp then its working fine. I just wanted to check how a single bean could be accessed from different places by using JSP standard action.

Thanks
Jayant
Login.jpg
[Thumbnail for Login.jpg]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65764
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any reason you are using JSP 1.x actions rather than the modern JSTL and EL? JSP 2.x came out 15 years ago.
 
Jay Josh
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know abt EL and JSTL. But just wanted to know how <jsp:useBean> elements works? Especially its attribute 'scope=application' and how the same bean could be accessed through other jsp pages.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65764
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK. It's obsolete and shouldn't be used, so I'm not sure how much attention your question will get. For the modern means, look into <c:set> (or follow best practices and set up scoped variables in the controller, not the JSP).
 
Jay Josh
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes agree but it is still taught in many j2ee courses in India. I have worked with JSTL and with all core library tags. Anyways thanks for your reply Bear Bibeault. I finally got it solved thanks to the following

http://www.javatpoint.com/jsp-setProperty-and-jsp-getProperty-action-tag
 
Stefan Evans
Bartender
Posts: 1831
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for completeness, I'm presuming the solution here was to include the jsp:useBean tag on the second page as well as the first.

i.e. add the useBean tag to FinalJsp.jsp



You need to declare you are going to use a bean on the page with the useBean tag before you can refer to it with a getProperty tag.
At that point it will either retrieve the bean from the appropriate scope, or if it is not present, create it.

Having said that, Bear's recommendations about not using them still stand.
JSP standards have come a long way since those tags were introduced.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!