What is Struts?

What is Struts???
LVL 3
InNoCenT_Ch1ldAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jimmackCommented:
http://jakarta.apache.org/struts/index.html

Not too much more to say really ;-)
0
jimmackCommented:
Actually, perhaps this could get quite interesting :-)

I've done quite a bit of JSP/Servlet development and (some time ago) I had a look at struts.  It wasn't really appropriate for what I wanted at the time, so I didn't go into it in too much detail.

I notice that there are a *lot* of jobs advertised at the moment that "require" struts experience.  However, on another web site (which shall remain nameless, because I can't remember which one it was ;-)) there was a very heated argument about the fact that struts was too "heavyweight" for all but the largest/distributed/complex web applications.  

This was being debated amongst developers that were bitching about the different servlet containers (Tomcat, Resin etc.).  The developers in question seemed (reasonably) well informed and experienced, so ... do any of the Struts-perts on EE have any comments regarding this?

Is struts too heavyweight?  Has it been incorrectly, inappropriately or indiscriminately applied?
0
jimmackCommented:
Please be reasonable in your comments, I don't want to start a flame war (nor would that be useful to anyone).
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

TimYatesCommented:
I am firmly of the view that almost *every* professional web-application should be expandable, and maintainable...

Say you have the following case:

--------------------------

A small dev team want an online intranet diary, so they can see what they are working on, and the manager can see how things are going, and book meetings, etc
It is obviously quicker to write this as a bespoke app, with jsp's, a db connection, and some hardcoded usernames/passwords, as that would give you a 2 day (week?) turnaround on the webapp's completion...

Assuming it is good enough, then the marketing team want to use it too...  No need for a rewrite, as it can accomodate these people (as they are on the same network)

Slowly, more and more people want to use the application....when does it need rewriting?  When does it become a large/distributed application?

Say you have more than one office, where people need to book meetings with users in the other office...  

Now it is an internet application...  

Are you sure it's secure enough?

---------------------

Basically, my point is, even when you are told that "this is just going to be used in-house by me and him", assume the worst...  assume it's going to have multiple users, all hammering it at the same time...

That way, you don't have the nightmare of trying to maintain, and update simultaneously a web-app that people have got so used to that they cannot live without...

Otherwise, you end up at work, at night, trying to import all the old data into the new system, and test it all is still working...

Struts gives you a very good foundation for extensibility...  and with modules, and tiles, etc....new things can be added in parallel to your existing application...

Just my 2p :-)

Tim
0
TimYatesCommented:
PS:  As usual, my example is contrived, and rubbish....but I hope it gets my point across :-)

PPS:  Another good reason for using Struts is (as jim says); "there are a *lot* of jobs advertised at the moment that "require" struts experience"

:-)
0
jimmackCommented:
Thanx Tim.

>> assume the worst

Always ;-)  And never rely on a requirement spec to be complete ;-)

>> Otherwise, you end up at work, at night, trying to import all the old data into the new system, and test it all is still working...

This sounds like hard-won experience ;-)
0
TimYatesCommented:
After seeing Jim's post in the interfaces question, I'll post my experiences with Struts

PRO-------------------------------

1)  It does allow you to separate your web-application's flow from the pages themselves...  This is GOOD, as I had a complete site redesign, and it only meant I had to edit my struts-config file to say where each form goes to on success or faliure (rather than edit every jsp)
2)  It handles i18n for you, I admit that I haven't used this -- I currently have one locale -- and it *does* require more thought than just throwing every bit of text into a properties file, but I know that as soon as French people complain they can't read my site, I can get a French speaking person to translate one file, and it will make my website french too (ish)
3)  It allows you to "modularise" your code -- using tiles.  Say you have a list of users that appears on more than one page, you can make this list a tile, and just put it wherever you want
4)  It handles file uploading -- using ithe commons libraries
5)  It handles tokens, so can stop multiple posts of the same page (like clicking submit loads on EE when asking a question doesn't) ;-)

CON-------------------------------

1)  The documentation is RUBBISH....  The books are RUBBISH...  The best resource is either here, or jguru (search on google with "site:jguru.com" in the search criteria)...  Even then, you end up with occasional days of trial and error...
2)  When you have something wrong, you more often than not get "JasperException: null" which is not very useful in the slightest :-(
3)  When storing your forms in the request, you cannot have userdefined types as form parameters...  This is a bit of a pain some times, as you then have to store the form in the session, which obviously increases the footprint of your application

That's all I can think of at the moment :-(

My best advice, is download struts1.1, and have a look at the examples...  They are probably the best resource out there, as I said, the books just seem to run through two or three contrived web applications, and do not give you lists of tags, parameters and examples (which is what you really want and need)

Tim
0
TimYatesCommented:
> This sounds like hard-won experience ;-)

Oh yes!  My record is a 56 hour stint with 3 other guys going from an oracle db on tape, to a completely (almost) working, multiple device, xml/xsl website...

Wish we had though a bit harder about version 1 -- or done some high load performance testing ;-) hee hee

Tim

0
TimYatesCommented:
> And never rely on a requirement spec to be complete ;-)

Hehehe, true...  And if the spec says "This will NEVER require XXX", then it WILL!  

9 times out of 10 this means that they thought of it, thought it would be cool, but can't afford to pay for it...  So as soon as the budget goes up a bit, it will become a new requirement...  Usually "floated in" during a management meeting :-(

Tim
0
TimYatesCommented:
Hehehe...I think I have wandered a bit off the topic of the question... ;-)

Ranty Tim
0
jimmackCommented:
>> "floated in"

Like a poo that won't flush away.  Yes.  I've been there too ;-)
0
dualsoulCommented:
hm...i didn't have much expirience with Struts, but i like it very much in a way i separate the view from logic code, it's really easy to maintain .

   What's about heavy-weight ... hm..it depends on what you did you mean :)
If you asked about speed...than Struts is just implement 'Front-Controller' , i've took a look at the sources, there are nothing more than one hashtable lookup+one forward :)

If you've asked about size, so for webapp of 3 pages, you may be don't need ~1Mb of .jar's :))
  but if you have ~10 pages, depending on each other, i think it's not big cost for good structure and clear appliction-flow :)
0
glottisCommented:
in a laymans term... i still couldnt figure out what Struts is... what cn it do... where it is used... :P

i think it is used in web development area... and as im on this project now... so ill look into Struts even more after the conversation you people just had.
0
InNoCenT_Ch1ldAuthor Commented:
tim and jim>> so, can i conclude that the structs is something like a template??
0
TimYatesCommented:
Yeah, it lets you template your web-pages, and keep the data (further away) from the design of the website :-)
0
InNoCenT_Ch1ldAuthor Commented:
ok, one last question, if i want to use this "struct", what working environment do i need? i mean like Java we use JDK, JRE....

does it require any sort of compiler?
0
TimYatesCommented:
yeah, you need the JDK, as forms need a javabean behind them (to hold the values from the form)...

Basically, you get to this situation:

1. [Pre processing -- before the page is displayed -- fill in values, lists, set tokens, etc]
2. JSP (or multiple jsp's templated together to form a page) containing the struts tags describing the form
3. Post processing...  validation of the form values, etc

The first item is optional (the form bean will get created for you if you miss this out), but then in the 3rd item, you will get passed the form bean so you can write code to update the database, and jump to another part of the site :-)

I guess the books are good, as they do give you examples, but none of them seem to give you all the information you will ever need (I remember my C "Bible" which had every ANSI function, what it did, and an example -- now THAT was a book) :-)

Tim
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InNoCenT_Ch1ldAuthor Commented:
ok, satisfy! ;p

-Child-
0
stevebeechCommented:
InNoCenT,

Just to clarify - Struts is a web application framework which employs the MVC pattern (Model View Controller) to separate the functional areas of the design into logical sections.

The View section will contains JSPs (or some other output format such as XML, XSL) to display data to the user and accept user input.
The Model is your back-end application (which has no concern abut display of info to the user)
The Controller is a Struts ActionController Servlet which maps http requests to Actions which in turn communicate with the model to retrieve data.

JavaBeans are used as ActionForms to contain data which may be passed between the model and view.

So, you'll need Servlets and JSP and JavaBeans which means getting JDK (J2SDK1.4) ensuring that it supports servlets. You'll also need a Servlet Container to run the app in - I suggest Tomcat.
And of course the Struts jar.

Cheers,

Steve
0
InNoCenT_Ch1ldAuthor Commented:
Thanks Stever for your additional information ;)

EE is always the place that full of wisdom, for trade ;p hehe

-Child-
0
jimmackCommented:
Thanks for the points InNoCenT_Ch1ld ;-)

Sorry to hijack the question there.  I hope that the responses were as useful to you as they were to me.  It was almost exactly what I hoped:  Solid comments, good opinions and no arguments ;-)

Jim.
0
InNoCenT_Ch1ldAuthor Commented:
;)

i hate arguments too!!
0
davidvilson2009Commented:
This may be very useful for you if any one is looking for struts interview questions.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.