Solved

What is Struts?

Posted on 2003-12-01
23
1,259 Views
Last Modified: 2013-11-24
What is Struts???
0
Comment
Question by:InNoCenT_Ch1ld
  • 8
  • 6
  • 5
  • +4
23 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9849225
http://jakarta.apache.org/struts/index.html

Not too much more to say really ;-)
0
 
LVL 15

Assisted Solution

by:jimmack
jimmack earned 25 total points
ID: 9849264
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9849267
Please be reasonable in your comments, I don't want to start a flame war (nor would that be useful to anyone).
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9849357
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
 
LVL 35

Expert Comment

by:TimYates
ID: 9849361
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9849387
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
 
LVL 35

Expert Comment

by:TimYates
ID: 9849402
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
 
LVL 35

Expert Comment

by:TimYates
ID: 9849409
> 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
 
LVL 35

Expert Comment

by:TimYates
ID: 9849416
> 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
 
LVL 35

Expert Comment

by:TimYates
ID: 9849421
Hehehe...I think I have wandered a bit off the topic of the question... ;-)

Ranty Tim
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9849441
>> "floated in"

Like a poo that won't flush away.  Yes.  I've been there too ;-)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 15

Expert Comment

by:dualsoul
ID: 9852841
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
 
LVL 2

Expert Comment

by:glottis
ID: 9856370
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
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9856433
tim and jim>> so, can i conclude that the structs is something like a template??
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9856632
Yeah, it lets you template your web-pages, and keep the data (further away) from the design of the website :-)
0
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9856652
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
 
LVL 35

Accepted Solution

by:
TimYates earned 25 total points
ID: 9856687
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
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9856748
ok, satisfy! ;p

-Child-
0
 

Expert Comment

by:stevebeech
ID: 9856807
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
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9856825
Thanks Stever for your additional information ;)

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

-Child-
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9856869
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
 
LVL 3

Author Comment

by:InNoCenT_Ch1ld
ID: 9863919
;)

i hate arguments too!!
0
 
LVL 1

Expert Comment

by:davidvilson2009
ID: 36190035
This may be very useful for you if any one is looking for struts interview questions.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now