• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

taglib in JSP not working in struts

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i am trying a piece of JSP code but i am not getting the required result. Can you help me please

When i am trying with the code below, it is showing the result, but text box and password box are missing. i have also attached the screenshot for this.




but the book which i am following, in that the .jsp page has coding like





but this code gives error and does not compile.


pease tell me what is the correct way of doing it ?


Also my struts-config file is like this




and my RegisterForm.java class is like







and my RegisterAction.java class is like this





now my question is .. from .jsp page, where i put the username and password1 and passwrd2 ..the RegisterForm is called and it's object is created ..but how does the RegisterForm claas knows which value from jsp page will go and get set into which RegisterForm class variable ?
output.JPG
[Thumbnail for output.JPG]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok first thing.

The only difference I can see between the two JSP snippets, is that one contains the taglib definition: <%@ taglib uri = "/WEB-INF/struts-html.tld" prefix="form" %> from the book example.
And the other doesn't but attempts to use those tags anyway.
If you want to use the tags, you have to declare the tag library.

Rather than referencing the tld, I would recommend using the URI for this tag library:
<%@ taglib prefix="form" uri="http://struts.apache.org/tags-html" %>

Make sure you have the struts libraries available to your web application in the WEB-INF/lib directory.



>now my question is ..
>from .jsp page, where i put the username and password1 and passwrd2 ..
>the RegisterForm is called and it's object is created ..
>but how does the RegisterForm claas knows which value from jsp page will go and get set into which RegisterForm class variable ?

It maps via javabeans properties.
If you have a property 'userName' it will call the method setUserName.
If you have a property 'password1' it will call the method setPassword1

Note that it will NOT call the method SetUserName() that you have defined in your class. Can you see why? (Hint: setUserName and SetUserName are two different functions)


 
reply
    Bookmark Topic Watch Topic
  • New Topic