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 JSP in Struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP in Struts" Watch "JSP in Struts" New topic
Author

JSP in Struts

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All I have a basic question how do we define buttons and dropdown in jsp when we are using struts.

Do I need to define form fields like button,textbox and dropdown in struts-config.xml file also if we are validating the actions.

One more question can anyone point to a good tutorial for taglib.


thanks
Anurag


SCJP 1.2
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982

Do I need to define form fields like button,textbox and dropdown in struts-config.xml file also if we are validating the actions.

NO. All form components are already defined by Struts' custom tags.

Validation of the form data are defined in validator.xml, not struts-config.xml.


Hi All I have a basic question how do we define buttons and dropdown in jsp when we are using struts.

You can use Struts' custom tag. For example, if you want to define the textfield, you cau put this in your JSP:


And in your action form, you have the corresponding variable, and its getter and setter:


Then, the Struts engine will know how to set the value from the JSP form to the Struts action form.


One more question can anyone point to a good tutorial for taglib.

Here is the Struts' tag reference.
http://jakarta.apache.org/struts/api/org/apache/struts/taglib/html/package-summary.html#package_description

Nick
thanks
Anurag[/QB]


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Forget to mention, about the validation.

The action form should be either ValidatorForm or DynaValidatorForm.


Then, Struts engine will display the errors in this form found.

Nick
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Nicholas Cheung:
...
Then, Struts engine will display the errors in this form found.

...assuming that you have placed <html:errors/> tags into the JSP generating the form's HTML


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341

Originally posted by Lasse Koskela

...assuming that you have placed <html:errors/> tags into the JSP generating the form's HTML


You can use the below code instead of <html:errors/> tag.

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Yep. The <html:messages/> is actually preferred over the older <html:errors/>
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi All,

Thanks a lot for your response, it will be really helpful for me.


thanks
Anurag
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Hi Lasse,


The <html:messages/> is actually preferred over the older <html:errors/>

What is the major different between the 2 tags?

Besides the general consideration that <html:messages/> can contain any messages, while <html:errors/> focus on error messages, other reasons for such recommendation?

Nick
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Originally posted by Nicholas Cheung:
What is the major different between the 2 tags?

Besides the general consideration that <html:messages/> can contain any messages, while <html:errors/> focus on error messages, other reasons for such recommendation?

This is the one reason I'm aware of. I remember hearing the "recommendation" from a Struts trainer but I can't remember whether he presented any arguments for that recommendation...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP in Struts