Introduction To Struts
Every now and then IT industry has come out with something new. It was Java in mid 90s and .NET in 2000 and so on.
All these things changed the way programmers write programs.
Java changed the preception of programmer. It let programmers concentrate on application logic
more than house-keeping issues like memory management and thread management.
.NET from Microsoft came in 2000 has provided a new platform for application development.
We say we develop applications for .NET and not Windows.
J2EE is widely accepted by industry. Java has grown from strength to strength in both Web application development and
enterprise application development. First came Servlets, then JSP, EJB and now Java Struts.
What is Java Struts?
If you are hearing this for first time then you are not alone. Not many know it as of now, but
at the same time many use it.
Struts is used to develop web applications. It is a web application framework based on JSPs, Servlets and Java Beans.
Struts project was initiated in May,2000 by Craig R. McClanahan and in July,2001 Struts 1.0 was released.
In MVC (Model-view-Controller) design pattern, Controller acts as a mediator between View (presentation)
and Model (data). Prior to Struts, MVC was implemented using JSPs. The entire development was JSP Centric.
In Model 2 of MVC, we use Servlets and JSPs. JSPs take care of generating HTML (view) and Servlets take care
of controlling the flow. Java Beans are used to contain model (data). Beans may take data from either a database
or an EJB or any other conceivable source.
View - Presentation
View portion is handled in Struts using JSPs. Struts provide a set of custom tags, which
internally generate HTML. The best part of it is these HTML pages can be very easily
internationalized. It means
the view portion can be in any language. It takes almost no time to shift an application from
English to Spanish.
View portion handled by custom tags is intergarted with Model, which is represented by Java Bean.
Controller - controlling the flow
Controller portion is handled by Servlet. ActionServlet in Struts takes request and decides which action should take place. The Action component
performs business logic and then transfer control to view portion for display.
What you need to use Struts?
The following are the component required to use Struts.
- Jakarta Struts library.Download struts library 1.1 , which is 16 MB.
- Tomcat 4.0 or highter
- JDK 1.4 to compile Java Beans
Do the following after you install Jakarta Struts 1.1.
- Unzip the .ZIP file into folder
- Copy struts-documentaion.war from webapps directory of the folder into
which you extracted ZIP file into webapps directory of Tomcat.
- Start Tomcat server
- Enter the url http://localhost:8080/struts-documentation. Struts documentation is provided as
one of the sample web applications.
First application
I have developed a simple Struts application. Download first.zip and extract it into
webapps directory of Tomcat. Then start tomcat and run the url http://localhost:8080/first to see
the sample application in action.
Java struts provides a few sample applications to demonstrate Struts. However, my application (first) will give an overview
of struts without overwhelming you.
Keep learning.
P.Srikanth