• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

taglib in JSP not working in struts

 
rammie singh
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • 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]
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64718
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.
 
Stefan Evans
Bartender
Posts: 1692
10
  • Mark post as helpful
  • send pies
  • 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)


 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic