File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes taglib in JSP not working in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "taglib in JSP not working in struts" Watch "taglib in JSP not working in struts" New topic
Author

taglib in JSP not working in struts

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
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 ?


[Thumbnail for output.JPG]

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61612
    
  67

Please be sure to ask Struts questions in the Struts forum. I have moved this post there for you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
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)


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: taglib in JSP not working in struts