Professional Documents
Culture Documents
Objectives
Generic Web Application Architecture J2EE Web Application Architecture CGI,Servlets and JSP Model 1 Architecture Model 2 Architecture - MVC MVC with Configurable Controller Struts Architecture First Look Struts Framework Components Struts Request Lifecycle Struts Simple Hello World Example in Eclipse
Client: Generally a browser(user agent) is controlled by a user to operate the Web application. The
Why J2EE ?
Technical Benefits Enables component based approach to develop enterprise web application. Reduces cost and complexity of developing large,multi-tier-web-based application. Component types supported,State management,Database caching,declarative (automated) persistance,scalability through load balancing. Buisness Benefits Indusrty buy-in and choice of vendors,greater utilization of existing IT assets. Faster response to change,choice of proven ,scalable and reliable platform.
Client tier supports both applet container and application client container. Applet container is the container to manage the execution of applets.Exam-ples of an applet container are applet viewer,web browser and java Plug-in running on the client together. Application client container is the one which is responsible for managing the application client components. Both application client and its container resides at the client machine and are executed on the client end. Example of application container is JVM.
Java EE Application Servers J2EE specification defines a whole lot of interfaces and a few classes.Implementations for these interfaces adhering to the J2EE specifications. These implementations are called J2EE Application Servers. Example : WebLogic by Oracle,WebSphere by IBM,Gerinomo,TomEE by Apache,Jboss etc
It was a platform-independent (As it is written completely in Java), component-based approach of developing web applications having dynamic content genration capabilities. Since it is written in Java hence all the tested and tried rich set of APIs of Java are readily available to be used and this advantage took this technology way above its competitors .
Model 1 Architecture
Consider a mediocre application with 15 JSPs. Assume that each page has five hyperlinks (or five form submissions). The total number of user requests to be handled in the application is 75. Since we are using MVC framework, a centralized controller servlet handles every user request. For each type of incoming request there is if block in the doGet method of the controller Servlet to process the request and dispatch to the next view. For this mediocre application of ours, the controller Servlet has 75 if blocks. Even if you assume that each if block delegates the request handling to helper classes it is still no good. You can only imagine how bad it gets for a complex enterprise web application. So, we have a problem at hand. The Controller Servlet that started out as the greatest thing next to sliced bread has gone bad. It has put on a lot of weight to become a Fat Controller.
View Category
It contains utility classes variety of custom tags making it easy to interact with the controller. It is not mandatory to use these utility classes. You can replace it with classes of your own.
f)Association of the logical name and the physical JSP page is encapsulated in the ActionForward instance returned from the execute method. In return mapping.findForward("success") RequestProcessor looks for the success attribute and forward to JSP page mentioned in success tag. i.e success.jsp. In return mapping.findForward("failure") RequestProcessor looks for the failure attribute and forward to JSP page mentioned in failure tag. i.e. failure.jsp In J2EE terms, this is referred to as dispatching the view to the user.
XML Java 1.web.xml 1.HelloWorldAction.java 2.struts-config.xml 2.HelloWorldForm.java JSP 1.HelloWorld.jsp 2.index.jsp http://struts.apache.org/download.cgi 3.failure.jsp
web.xml
struts-config.xml
HelloWorldAction.java
HelloWorldForm.java
HelloWorldForm.java
index.jsp
HelloWorld.jsp
failure.jsp
STEPS TO EXECUTE
Create dynamic web project in eclipse 2. Add jsp,xml and java files according to directory structure. 3. Add struts libraries in Web-INF/lib folder. 4. Add same struts libraries in java build path(Right click on main project ->properties->java build path->libraries ->add external jar 5. Add tomcat server (Windows menu -> show view ->servers ->OK 6. Go to server wizard -> add new server - >Apache -> select the tomcat version you downloaded ->Next ->Browse ->select the folder where you extracted or installed the downloaded tomcat ->finish 7. After adding server,right click on Project-> Run as -> Run on Server ->select server you added ->Finish
1.
return mapping.findForward(failure)
Feedback :wadekaranup@gmail.com