File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Jsp in Struts

Venkatesh Kumar
Ranch Hand

Joined: Aug 08, 2003
Posts: 68
Hi :

I would like to know if a jsp page to be used in struts framework should always be developed using struts custom tags.Cant we use the normal jsp pages ??

Kim Lilienfeld

Joined: Apr 13, 2004
Posts: 25
Ok, I don't know the "correct" answer to that question so this is only my opinion...

I found the great thing about struts is that it reduced the complexity of jsps especially when it came to retrieving information from and displaying information on a web page. I find the simplicity of it beautiful (ok, I'm a geek)!

Lets look at a textfield in a jsp.. Using the struts tags you would code the following:
<html:text property="formVariable" size="15"/>

If you wanted to display a value, its a simple case of in your action typing
aForm.setFormVariable("My Value");
And Voila! "My Value" is displayed in the textfield... and if someone enters a value then in you simply need to type (in ur action):
String theEnteredValue = aForm.getFormVariable();

How simple is that!!! Ok, so you do need to do some extra things like add the form and action to the struts-config, specify what is associated with a particular jsp and ensuring all your variables are in your form class - but personally, it just makes my life a whole lot easier which means I get extra time to surf the net at the end of the day

And its especially great when you initialise your form with a Value Object or export a Value object from your form so that you don't have to initialise each variable in the object!

Ok, thats my 2 cents!
Priya Jotwani
Ranch Hand

Joined: Oct 30, 2002
Posts: 53
Well, AFAIK it is not mandatory to develop your JSPs using Struts though you would be not utilizing it 100% .You can as well use normal JSP tags with Struts framework.
Any Comments ??

I agree. Here's the link:
subject: Jsp in Struts
jQuery in Action, 3rd edition