DTS Web Developers Guide
|
|
|
- April Arnold
- 10 years ago
- Views:
Transcription
1 Apelon, Inc. Suite 202, 100 Danbury Road Ridgefield, CT Phone: (203) Fax: (203) Apelon Distributed Terminology System (DTS) DTS Web Developers Guide
2 Table of Contents Introduction... 3 Architecture Overview... 3 The Jakarta Struts Framework... 3 Servlet Specification and Java Server Pages... 6 Prerequisite Software... 7 Setting Up a Web Application... 9 The web.xml File... 9 The struts-config.xml File The server.xml File Connecting the Dots Guidelines for Developing a Web Application Guidelines for Action Classes Scope Naming Responsibilities Guidelines for Developing Forms Scope Responsibilities Guidelines for Writing Java Server Pages Scope Responsibilities Creating Your Own DTS Web Application References Page 2 of 23
3 Introduction The DTS Browser is part of the Apelon DTS client/server solution. The DTS Browser is provided as an example of a web application that can be developed using Apelon DTS. The entire source of the application has been provided to you. You can develop your own application according to your needs by using or extending the DTS Browser application. The purpose of this document is to give you, the developer, the resources needed to develop web applications that use the Apelon DTS or to extend the DTS Browser. This guide assumes that you understand basic Java development. You also should be familiar with general concepts in developing HTML, XML, Servlets, Java Server Pages and the Apelon DTS API. Architecture Overview The Apelon DTS API is written in the Java Programming Language (JDK 1.5). The natural choice for web applications using the DTS API is J2EE - Sun Microsystems Java Platform 2 Enterprise Edition. Part of the J2EE specification is the Servlet specification, which is a solution for running web applications. The DTS Browser is based on the Apache Foundation s Struts Web Application Framework (Struts). Struts is written using Java s Servlet Specification and also uses Java Server Pages (JSP). The Jakarta Struts Framework Struts is an open source framework, developed for encouraging an application architecture based on the Model-View-Controller (MVC) design paradigm. Struts now is part of the Apache Software Foundation (ASF) Jakarta project. Strut s official home on the web is The Struts mailing list can be found at An archived mailing list can be found in the Mail Archive ( - search for struts ). Struts consists of these four basic components: 1. ActionServlet a single Servlet that controls all requests to the web application. The ActionServlet reads requests, routes the request to be validated (by an ActionForm class), routes the request to be handled (by an Action class), and finally sends the response with any results back to the client (usually a browser). 2. ActionForm Classes the ActionServlet populates ActionForm classes with data from a HTTP request. Once populated with data, the ActionForm provides validation so that only valid data makes it into the system. Page 3 of 23
4 If data in the AcitonForm is valid, the ActionServlet sends the ActionForm to an Action for handling. If errors are found during validation, there is a shared mechanism available in the framework for raising and displaying error messages. ActionForms can also be used to populate HTML forms in JSP pages. 3. Action Classes Actions invoke methods on objects in your application to perform the actual business logic. Actions are best used to focus on error handling and control flow. While an Action can implement business logic of the application, Actions are most effective when they invoke methods on other objects so that the logic of the application is separated from the flow and control of the web application. 4. Utilities Struts provides utilities for parsing XML and also several Tag Libraries for use in JSP pages. The Tag Libraries supplied by Struts allow JSP integration into the Struts framework. While the use of these libraries is not required to use the framework, you may want to explore them. These libraries include the following: Struts-html tag library - used for creating dynamic HTML user interfaces and forms. Struts-bean tag library - provides substantial enhancements to the basic capability provided by <jsp:usebean>. Struts-logic tag library - can manage conditional generation of output text, looping over object collections for repetitive generation of output text, and application flow management. Struts-template tag library - contains tags that are useful in creating dynamic JSP templates for pages, which share a common format. The code and descriptors that support the Struts tag libraries are distributed with the struts.jar archive. You can include these web libraries by modifying the web application descriptor file, web.xml (see the section Setting up a Web Application for more details). Page 4 of 23
5 For more information about Struts Tag Libraries see the Developer Guide and TagLib Documentation sections on the Struts release page ( Using the components described, Struts implements a Model-View-Controller (MVC) design pattern within the Servlet architecture. The following components make up the Model, View and Controller components of the framework. Your application logic ( Business Logic Objects in the diagram above), your data and the Apelon DTS make up the Model Layer of the framework. Page 5 of 23
6 The View Layer contains JSP pages, HTML pages, and Struts Form classes that carry data from the view to the Controller. When errors occur the Form class can also carry data back to the JSP. The Struts ActionServlet class coupled with Struts Action classes comprises the Controller Layer. The ActionServlet dispatches incoming requests to an appropriate Action class, which updates the Model Layer components. The dispatch from the controller to the Action class is based on a configuration that is provided by an XML file. Struts Forms are also used to validate and carry data to the Action class. So you could say that Struts Forms are a part of the Controller as well as the View Layer. The diagram illustrates the relationship between the different components of the Web application framework and how they work together. Servlet Specification and Java Server Pages Because Struts uses the Servlet architecture, here are a few points that will help you while developing your application: 1. Servlets are grouped as part of a Web Application called an Application Context. a. A Servlet Engine can run multiple web applications; each application has its own Application Context defined by a XML descriptor file called web.xml. b. Your application may not be the only application running on the server so be aware of your shared environment. 2. Servlets are Asynchronous because requests can be sent across an asynchronous TCP/IP network, application state is lost between requests unless explicitly stored in memory or a database. a. An HttpSession object is provided in the Servlet architecture for saving state between requests all Struts Actions have access to this object via the HttpServletRequest object passed to it by the ActionServlet. b. Java Database Connectivity (JDBC) and or Enterprise Java Beans (EJB) can be coupled with the Servlet architecture to save state to a database between requests. This is a better solution when you are running the same application on multiple servers. This allows you to share state between servers so any server can handle user requests. 3. There is only one instance of each Servlet in a web application. a. Servlets are very efficient because they pass requests to threads that can run simultaneously. When developing an application you need to be aware that your application will be running in a multi-threaded environment sharing a single instance of the ActionServlet and each Action class. Page 6 of 23
7 4. JSP s are compiled and run in a Servlet Engine as a Servlet. a. Don t let the name fool you, JSP pages are not just HTML pages with a fancy name. JSP s are in fact Servlets and can do what ever a Servlet can do. b. Because JSP s are Servlets they can do a lot more than just present a view. However, to fit well into the Struts architecture JSP s should only include logic provided by Java Server Page Tag Libraries. This provides a separation of responsibilities so your code can be concentrated in your application, not in a group of web pages. These few points are important to understand, but there is a lot more to the Servlet and Java Server Pages specifications. If you would like to review more details about Servlets, go to You ll find more details about JSP at Prerequisite Software The following software resources are required or recommended when developing DTS Browser source code: A Java based Development IDE such as Borland s JBuilder IntelliJIDEA or Eclipse (recommended) XML Parser (required) xerces.jar. o Description: XML parsing classes distributed by the Apache Foundation. o Used at: Run time o Location: Apelon\DTS\tomcat\common\lib. However, when compiling the source code, use parser.jar and jaxp.jar since the com.apelon.common.dom package uses the Sun parser instead. In JBuilder this can be accomplished by including parser.jar and jaxp.jar in the project s Required Libraries, but excluding them from the Dependencies of the project s Web Application component. Servlet API Classes (required) servlet.jar. o Description: Java extensions for support of Servlets and Java Server Pages o Used at: Compile time and run time o Location: Apelon\DTS\tomcat\common\lib. Page 7 of 23
8 One of the following: o ojdbc14.jar o Sprinta2000.jar (if SQL Server is used) o Used at: Compile time and run time. o Location: Apelon\DTS\tomcat\lib. Logging (required) log4j.jar o Description: Application logging utility classes. o Used at: Compile and run time. o Location: You can find it in the WAR file. The WAR file is located at Apelon\DTS\tomcat\webapps\dtstreebrowser.war. If you have run the Tomcat server once, you can find the log4j.jar at Apelon\DTS\tomcat\ webapps\dtstreebrowser\web-inf\lib also. Struts Application Framework (required) struts.jar, commons-beanutils.jar, commons-collections.jar, commons-digester.jar o Description: Struts is a web application framework from the Apache Foundation. o Used at: Compile and run time. o Location: You can find it in the WAR file. The WAR file is located at Apelon\DTS\tomcat\webapps\dtstreebrowser.war. If you have run the Tomcat server once, you can find the struts.jar at Apelon\DTS\tomcat\ webapps\dtstreebrowser\web-inf\lib also. o Notes: DTS Browser source code is extended from classes found in this archive. All of these jar files should be placed in JBuilder s Required Libraries list. Tomcat 5.5 or higher (recommended) This is a web server to run the DTS Browser. You can download it at Ant (recommended) This is used to do the build and make the WAR file. You can download it at In order to build your [dtstreebrowser].war file you need to create the build.properties file and build.xml file and run Ant. To see a detail discussion, go to After you get your [DTSBrowser].war file built, you can install it in a Tomcat Server. For installation information refer to the DTS Browser Installation Guide. Page 8 of 23
9 Setting Up a Web Application The web.xml File A single ActionServlet will handle all requests that are made to your web application. In the case of the DTS Browser this class is com.apelon.struts.common.apelonactionservlet. java that extends the Struts ActionServlet. Before being able to use Struts, you must set up a web application to run inside a Servlet Engine (also referred to as a JSP container). The Servlet Engine must be configured so that it knows to map all requests for your web application to the ActionServlet for handling. The configuration of the web application is done using an XML descriptor called web.xml. The Servlet Engine reads the web.xml file at start up. The web.xml file allows you to tell the Servlet Engine the following: 1. The class that implements the ActionServlet 2. The start up parameter values needed when the ActionServlet is initialized 3. An URL extension mapping to the ActionServlet 4. The location of any Tag Libraries that you will use In the case of the DTS Browser, the web.xml maps all requests with an URL ending in.do to the ApelonActionServlet. The following example displays how this is done: <?xml version="1.0" encoding="iso "?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN" " <web-app> <servlet> > <servlet-name>action</servlet-name> <servlet-class>com.apelon.struts.common.apelonactionservlet</servletclass> <!-- The next two lines define the action servlet to the Servlet Engine -- <servlet>... <!-- maps all requests with extension of *.do to the Action Servlet --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping>... </web-app> The discussion in the next section relates to how the ApelonActionServlet processes.do requests. More examples are provided in the Guidelines for Developing Web Applications section later in the guide. Page 9 of 23
10 The web.xml file also defines to the Servlet Engine the location of Tag Libraries that can be used in JSP pages. In the case of the DTSBrowser, three Tag Libraries are used. Displayed is a snippet from the DTSBrowser web.xml file:... <web-app>... <!-- the DTS Browser uses the bean, html and logic Tag Libraries from Struts --> <taglib> <taglib-uri>/web-inf/struts-bean.tld</taglib-uri> <taglib-location>/web-inf/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/web-inf/struts-html.tld</taglib-uri> <taglib-location>/web-inf/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/web-inf/struts-logic.tld</taglib-uri> <taglib-location>/web-inf/struts-logic.tld</taglib-location> </taglib> </web-app> In the above example, the <taglib-location> tag references a local file for the Tag Library Definition files (*.tld). In this case, the tag library definition files used by the DTS Browser have been extracted from the struts.jar file for convenience. Now that the web.xml file references the Tag Library, you can use this library in a JSP. To reference a Tag Library, you need to include a taglib directive at the top of your JSP. Each Tag Library that the JSP will reference needs its own taglib directive. Note an example of a tag-lib directive: <%@ taglib uri="web-inf/struts-logic.tld" prefix="logic" %> If the taglib directive above is included in the JSP, the Struts JSP Logic Tag Library can be included in the page. Here is an example of a call to the logic Tag Library: <logic:iterate id="concept" name="concepts" scope="request">... Code to execute here... </logic:iterate> The example illustrates a call to the iterate tag in the Logic Tag Library. A full description of the Logic Tag Library can be found at Page 10 of 23
11 The struts-config.xml File The ActionServlet can also be configured with a XML descriptor of its own. The web.xml file specifies as one of the parameters to the ActionServlet a parameter called config. The config parameter points to the struts-config.xml file, which configures the ActionServlet. When the Servlet Engine initializes the ActionServlet, the ActionServlet reads the struts-config.xml file. The relationships are stored in memory for optimal performance as an ActionMapping object. The struts-config.xml file provides the ActionServlet with the following: 1. Mappings of URLs to the Action class that will handle the request. 2. Mappings of Action classes to their required Form class 3. Mapping of names to locations where Actions forward control In short, the struts-config.xml file is really the glue of the entire framework. While web.xml defines where a request should go upon arriving, struts-config.xml provides the mappings so the ActionServlet can determine exactly what should happen to it. The advantage of using a single configuration file is a modular system that is easier to maintain. It prevents the hard coding of URLs to be called within a component. Changes can be made by updating the configuration file without having to recompile or re-deploy applications. When the ActionServlet starts up, it reads the struts-config.xml file and creates an ActionMapping object. This ActionMapping object is then used by the ActionServlet to look up locations for Actions, ActionForms and JSPs that were defined in strutsconfig.xml. The ActionServlet keeps a reference of the ActionMapping object until it is stopped. So if you update the struts-config.xml file, you have to stop and restart the ActionServlet before those changes take effect at runtime. In most cases this means you ll need to stop and restart your Servlet Engine after you make a change. The server.xml File One of the key elements in configuration of the server.xml file is the context tag for adding new web applications. View the Context Container discussion at the following link for details: View the Overview discussions at this link for general server.xml file information: Page 11 of 23
12 Connecting the Dots Now that we ve reviewed the components of the framework and how to set the system up, let s look at what happens to a single request in the framework. The following diagram represents the DTS Browser application running inside the Java Virtual Machine (JVM). The DTS Server runs in a separate JVM process. Communication between the two processes is done via XML over socket connections. In the diagram, the DTS Browser with the Struts framework is running inside the Servlet Engine on JVM 1. The DTS Server is running on JVM 2, which could even be on a different machine. The diagram assumes that the Servlet Engine (Tomcat in this case) is up and running, previous requests have already been handled and several sessions have already been created for two users. Page 12 of 23
13 The following steps correspond to the steps numbered on the diagram. 1. A user generates a request from a web page and the Servlet Engine routes the Request to the ActionServlet for handling. 2. The ActionServlet populates the ActionForm from the HTTP Parameters in the request. 3. The ActionServlet validates the form and sends it to the Action for processing along with references to the Mapping object, the Request Object, and the Response Object (not shown). 4. The Action sends messages to a custom object that handles the business logic of the application. 5. The custom object communicates with the Apelon DTS via a socket connection. 6. The result of the Action s processing is stored in the Request as an object (also referred to as a Bean). 7. The Request is forwarded by the ActionServlet to the appropriate JSP for display back to the user s web browser. Page 13 of 23
14 Guidelines for Developing a Web Application Once the environment is configured, the web application needs the logic and presentation to make it work. This section provides some guidelines that will help you develop a web application using Apelon DTS. Guidelines for Action Classes By the time a request gets to the Action Class, the ActionServlet has already parsed the request, all form validation has already been handled by the Form Class and the request has already been routed to the right place. An Action Class then sends the request s message to your application, handles any errors and directs the request to the next location. The Struts framework does not limit the amount or type of code that you place in an Action. In fact, you can place all your application logic in Action Classes if you want to. However, if you want to separate your business logic from your Web interface, Action Classes are best used to invoke another object to perform the actual business logic. This lets the Action focus on error handling and control flow rather than business logic. Scope Actions should have a very specific purpose. Optimally, an Action should support a single type of action or a few related actions in an application. Actions are the messengers from a view to object containing the application logic. Actions should only have a single method implemented, the perform( ) method. In this scenario, the application that is being acted upon should provide an interface of objects and methods that would allow any type of user interface to interact with it, not just a web interface. Actions should be unaware of anything about the application except for what it is passing to the application and the objects it gets back as a result. Here are some examples of good uses of Actions: 1. Log a user into the system. 2. Save data entered into a form. 3. Update a list of items. Naming Action names should reflect the purpose of their existence. Here are examples of names: 1. LoginAction - Logs a user into the system 2. SaveConceptsAction - Saves a list of concepts selected by a user to a database. 3. UpdateConceptListAction - Updates the application's concept list with a new concept. Page 14 of 23
15 Responsibilities Actions can have any of the following responsibilities in the perform method: 1. Retrieve the data from a form for this request. 2. Retrieve any business logic objects from the Application, Session or Request scope that require action. 3. If needed, create any new business logic objects that the application may need. 4. Call methods on the business logic objects to complete the action. 5. If needed, store the business logic objects in the Application object, Session object, or a database for future requests. 6. If needed, store the results of the action in the Application context, Session object or Request object for the view. 7. Handle any errors that may occur in the application. 8. Determine the view object to forward to and return a reference to that view as an ActionForward object. When limited to these responsibilities, Action Classes have the effect of separating the logic of an application from its web interface. Example Let s say that we are working on an application. This example has the following strutsconfig.xml that we are working on: <struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> <form-bean name="saveform" type="com.apelon.testapp.saveform"/> </form-beans> <!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name="error" path="/error.do"/> </global-forwards> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action path="/error" type="com.apelon.testapp.erroraction" scope="request"> <forward name="error" path="/error.jsp"/> </action> <action path="/save" type="com.apelon.testapp.saveaction" scope="request"> <forward name="success" path="/confirm.jsp"/> </action> </action-mappings> </struts-config> This struts-config.xml refers to a global forward. The type of forward is available to any Action. The global forward called error is overridden by a local forward called error defined with the ErrorAction. Page 15 of 23
16 This means that if ErrorAction s code refers to the string error the ActionServlet will map the forward to /error.jsp. However, if SaveAction s code refers to the string error, the ActionServlet will map it to /Error.do, another Action. In the example, the SaveAction is our first action (see the source below). The application is an editing application and has a business logic object called "workingdoc" stored in the user's session. The workingdoc is an instance of a SecureDocument that will be edited by the user during this session. The SaveAction s design is to send a message to the document to save itself. You will see that the SaveAction only sends the message to the SecureDocument object. The SaveAction does not actually do any of the saving. Once the save action is complete, the action stores a key in the request for the view to display. So in this example there are no inputs from a form, and there is a single output: the key of the document stored. If errors occur, the Action stores the error message an error object and sends control to an error view. If no errors occur, the Action stores the key and sends it to success or /confirm.jsp. public class SaveAction extends Action { public ActionForward perform(actionmapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ // Reference to an errors object that may be needed if we have exceptions. ActionErrors errors = null; // get a reference to this user's session. HttpSession session = request.getsession(); // get the business logic object needed for this action. SecureDocument doc = (SecureDocument)session.getAttribute("workingDoc"); // Document Key object of the document we will save so we can open it later. Key key = null; // the document is sent the message to save itself returning a key. try{ key = doc.save(); catch (Exception e){ // the application had some problems executing so handle that here. errors = new ActionErrors(); errors.add(actionerrors.global_error, new ActionError("error.savefailed", e.getmessage())); saveerrors(request, errors); // display the error view return (mapping.findforward("error")); // store the key of the document in the request for use in the next context. request.setattribute("dockey", key); // display the success view. return (mapping.findforward("success")); Page 16 of 23
17 This example did the following: 1. Retrieved an application object from the session. 2. Executed a method on that object. 3. Handled any errors that may have resulted. 4. Saved the resulting object in the request. 5. Sent control of the web application to the next location a. If errors occurred, forwarded to a forward location called error b. If successful, forwarded to a forward location called success Guidelines for Developing Forms Forms are simply JavaBeans. Forms consist of the following: 1. Private String properties to hold parameter data passed from an HTTP request. 2. Setter methods for setting property values. 3. Getter methods for getting property values. 4. Validation method to validate the properties before the Action can use them. 5. Reset method to reinitialize the form for reuse by subsequent requests. (Forms are reused to save on memory in the Servlet Engine.) That s all there is to a Form. The ActionServlet first populates the Form with data from the request by using the public setter methods. The ActionServlet then calls the validate method on the Form. If valid, the Form is sent to the Action who can then get any of the properties on the Form. Scope A single Form class can be mapped to several Action classes. While you can map a single form to a single Action, there is no reason why a Form class cannot be more general. For instance, your application may have several different types of searches. Each search has its own Search Action such as ConceptSearchAction, RoleSearchAction and PropertySearchAction. If the parameters sent to each of these Actions are the same, only one Form is needed: SearchForm. SearchForm can then be mapped to each of the search actions in the struts-config.xml. This consolidates code and takes complexity out of your application. Responsibilities The only responsibility that is needed in a Form is the validation method. The validation method should confirm that all the Strings sent from the client in the request are valid. If they are not valid for your application, then you have two choices: either update the value to some default and continue or send an error back to the user. Page 17 of 23
18 Example Let s continue the example from the Actions section discussed earlier. Here is the strutsconfig.xml file again, but the save action has been updated to now use a form. <struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> <form-bean name="saveform" type="com.apelon.testapp.saveform"/> </form-beans> <!-- ========== Global Forward Definitions ============================== --> <global-forwards> <forward name="error" path="/error.do"/> </global-forwards> <!-- ========== Action Mapping Definitions ============================== --> <action-mappings> <action path="/error" type="com.apelon.testapp.erroraction" scope="request"> <forward name="error" path="/error.jsp"/> </action> <action path="/save" type="com.apelon.testapp.saveaction" name="saveform" scope="request"> <forward name="success" path="/confirm.jsp"/> </action> </action-mappings> </struts-config> Save form has been defined as such: public class SaveForm extends ActionForm { private static final String ENCRYPTION = encrypted ; private static final String CLEARTEXT = cleartext ; private static final DEFAULT_VALUE = CLEARTEXT; private String type = null; public String gettype(){return type; public void settype(string value){type = value; public void reset(actionmapping mapping, HttpServletRequest request){ super.reset(mapping, request); type = DEFAULT_VALUE; public ActionErrors validateform(actionmapping mapping, HttpServletRequest request){ ActionErrors errors = new ActionErrors(); Page 18 of 23
19 // if no value or value is not expected set to default. if (this.type == null (!type.equalsignorecase(encryption) &&!type.equalsignorecase(cleartext))) this.type = DEFAULT_VALUE; return errors; So SaveForm is very simple. It has one property called type. When the SaveForm is validated, if type is not set to a value or it is set to a value we don t expect, type is set to the default value. This ensures that any Action that uses a SaveForm will always have a valid value for property type. Here s the updated Action class that will now use this Form (updates in bold): public class SaveAction extends Action { public ActionForward perform(actionmapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ // Reference to an errors object that may be needed if we have exceptions. ActionErrors errors = null; // get the type of document to save entered by the user String type = ((SaveForm) form).gettype(); // get a reference to this user's session. HttpSession session = request.getsession(); // get the business logic object needed for this action. SecureDocument doc = (SecureDocument)session.getAttribute("workingDoc"); // Document Key object of the document we will save so we can open it later. Key key = null; // the document is sent the message to save itself returning a key. try{ key = doc.save(type); catch (Exception e){ // the application had some problems executing so handle that here. errors = new ActionErrors(); errors.add(actionerrors.global_error, new ActionError("error.savefailed", e.getmessage())); saveerrors(request, errors); // display the error view return (mapping.findforward("error")); // store the key of the document in the request for use in the next context. request.setattribute("dockey", key); // display the success view. return (mapping.findforward("success")); Page 19 of 23
20 Guidelines for Writing Java Server Pages As discussed earlier in this document, Java Server Pages are Servlets and can do anything a Servlet can do. However, this does not always make for the best design of a system. Scope JSPs in the Struts architecture are used as simple views that place dynamic content into HTML pages. The content comes from objects that are saved either in the Application Context, the Session or a Request. The JSP should not be required to perform any logic against these objects. If logic is required, it should be placed either in the application or if necessary a Struts Action class. By keeping the scope of the JSP to the View Layer only, code is kept in your application making your project more manageable. Responsibilities JSPs should have the following simple responsibilities: 1. Retrieve objects saved in the Session, Request or Application contexts. 2. Insert dynamic content into a page a. Iterate over collections of objects (using the Struts logic Tag Library) b. Print values of object properties to the page. 3. Post data back to the server using the HTTP protocol Example a. This can be done using plain HTML, but Struts also provides the html Tag Library to help integrate HTML forms into the framework. Here is an example of the confirm.jsp that is part of the above example code. If you recall, the SaveAction forwards to a location called success. The struts-config.xml maps success to the confirm.jsp page. Confirm.jsp shows a user that the document has indeed been saved and will display the key number of the document to the user (the SaveAction placed a key object into the request for the JSP to use). <%@ taglib uri="/web-inf/struts-bean.tld" prefix="bean" %> <html> <title>confirm.jsp</title> <body> <center> <h1>your document has been successfully saved!</h1> <p> The key to your document is <bean:write name="dockey" property="code" />. </p> <p> Keep this code to open the document in the future. </p> </center> </body> </html> Page 20 of 23
21 The Key class has a single property called code that is accessed by the write tag of the bean Tag Library. Here s the source for the Key class: public class Key { private String code; public Key(){ this.code = CodeGenerator.createCode(); public String getcode(){ return code; Here s what the confirm.jsp page prints out to the browser: Page 21 of 23
22 Creating Your Own DTS Web Application Before beginning your own application or extending the DTS Browser, the following references will help you when coupled with this document: 1. The DTS Browser JavaDoc 2. The DTS Browser source code 3. Struts documentation a. Home page: b. User Guide: index.html c. Java Doc: The Struts home page has excellent Developer Guides for each of the Tag Libraries. Look for links on the User Guide page. Page 22 of 23
23 References Web Sites Struts: Servlets: Java Server Pages: Books Core J2EE Patterns: Best Practices and Design Strategies by Deepak Alur, John Crupi and Dan Malks, Prentice Hall. Java Servlet Programming by Jason Hunter with William Crawford, O Reilly. Web Development with Java Server Pages by Duane K. Fields and Mark A. Kolb, Manning. Back to Top Page 23 of 23
Tutorial: Building a Web Application with Struts
Tutorial: Building a Web Application with Struts Tutorial: Building a Web Application with Struts This tutorial describes how OTN developers built a Web application for shop owners and customers of the
In this chapter, we lay the foundation for all our further discussions. We start
01 Struts.qxd 7/30/02 10:23 PM Page 1 CHAPTER 1 Introducing the Jakarta Struts Project and Its Supporting Components In this chapter, we lay the foundation for all our further discussions. We start by
Development. with NetBeans 5.0. A Quick Start in Basic Web and Struts Applications. Geertjan Wielenga
Web Development with NetBeans 5.0 Quick Start in Basic Web and Struts pplications Geertjan Wielenga Web Development with NetBeans 5 This tutorial takes you through the basics of using NetBeans IDE 5.0
Web Container Components Servlet JSP Tag Libraries
Web Application Development, Best Practices by Jeff Zhuk, JavaSchool.com ITS, Inc. [email protected] Web Container Components Servlet JSP Tag Libraries Servlet Standard Java class to handle an HTTP request
Developing Java Web Applications with Jakarta Struts Framework
130 Economy Informatics, 2003 Developing Java Web Applications with Jakarta Struts Framework Liviu Gabriel CRETU Al. I. Cuza University, Faculty of Economics and Business Administration, Iasi Although
Web Application Architecture (based J2EE 1.4 Tutorial)
Web Application Architecture (based J2EE 1.4 Tutorial) 1 Disclaimer & Acknowledgments Even though Sang Shin is a full-time employee of Sun Microsystems, the contents here are created as his own personal
Glassfish, JAVA EE, Servlets, JSP, EJB
Glassfish, JAVA EE, Servlets, JSP, EJB Java platform A Java platform comprises the JVM together with supporting class libraries. Java 2 Standard Edition (J2SE) (1999) provides core libraries for data structures,
Struts Tools Tutorial. Version: 3.3.0.M5
Struts Tools Tutorial Version: 3.3.0.M5 1. Introduction... 1 1.1. Key Features Struts Tools... 1 1.2. Other relevant resources on the topic... 2 2. Creating a Simple Struts Application... 3 2.1. Starting
Services. Custom Tag Libraries. Today. Web Development. Role-Based. Development. Code Reuse. Tag Libraries Custom Tags. Tag Lifecycle.
JSP, and JSP, and 1 JSP, and Custom Lecture #6 2008 2 JSP, and JSP, and interfaces viewed as user interfaces methodologies derived from software development done in roles and teams role assignments based
WEB APPLICATION DEVELOPMENT. UNIT I J2EE Platform 9
UNIT I J2EE Platform 9 Introduction - Enterprise Architecture Styles - J2EE Architecture - Containers - J2EE Technologies - Developing J2EE Applications - Naming and directory services - Using JNDI - JNDI
Complete Java Web Development
Complete Java Web Development JAVA-WD Rev 11.14 4 days Description Complete Java Web Development is a crash course in developing cutting edge Web applications using the latest Java EE 6 technologies from
Building Web Applications, Servlets, JSP and JDBC
Building Web Applications, Servlets, JSP and JDBC Overview Java 2 Enterprise Edition (JEE) is a powerful platform for building web applications. The JEE platform offers all the advantages of developing
CrownPeak Java Web Hosting. Version 0.20
CrownPeak Java Web Hosting Version 0.20 2014 CrownPeak Technology, Inc. All rights reserved. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical,
Course Name: Course in JSP Course Code: P5
Course Name: Course in JSP Course Code: P5 Address: Sh No BSH 1,2,3 Almedia residency, Xetia Waddo Duler Mapusa Goa E-mail Id: [email protected] Tel: (0832) 2465556 (0832) 6454066 Course Code: P5 3i
Web Application Developer s Guide
Web Application Developer s Guide VERSION 8 Borland JBuilder Borland Software Corporation 100 Enterprise Way, Scotts Valley, CA 95066-3249 www.borland.com Refer to the file deploy.html located in the redist
Introduction to J2EE Web Technologies
Introduction to J2EE Web Technologies Kyle Brown Senior Technical Staff Member IBM WebSphere Services RTP, NC [email protected] Overview What is J2EE? What are Servlets? What are JSP's? How do you use
Portals, Portlets & Liferay Platform
Portals, Portlets & Liferay Platform Repetition: Web Applications and Model View Controller (MVC) Design Pattern Web Applications Frameworks in J2EE world Struts Spring Hibernate Data Service Java Server
Mastering Tomcat Development
hep/ Mastering Tomcat Development Ian McFarland Peter Harrison '. \ Wiley Publishing, Inc. ' Part I Chapter 1 Chapter 2 Acknowledgments About the Author Introduction Tomcat Configuration and Management
MVC pattern in java web programming
MVC pattern in java web programming Aleksandar Kartelj, Faculty of Mathematics Belgrade DAAD workshop Ivanjica 6. -11.9.2010 Serbia September 2010 Outline 1 2 3 4 5 6 History Simple information portals
PowerTier Web Development Tools 4
4 PowerTier Web Development Tools 4 This chapter describes the process of developing J2EE applications with Web components, and introduces the PowerTier tools you use at each stage of the development process.
Model-View-Controller: A Design Pattern for Software. June 2004
Model-View-Controller: A Design Pattern for Software June 2004 Introduction Why focus on Model-View-Controller Architecture? What's a Software Design Pattern? Why should programmers care about Design Patterns?
Web Application Development Using Borland JBuilder 8 WebLogic Edition
Web Application Development Using Borland JBuilder 8 WebLogic Edition Jumpstart development, deployment, and debugging servlets and JSP A Borland and BEA White Paper By Sudhansu Pati, Systems Engineer
Crawl Proxy Installation and Configuration Guide
Crawl Proxy Installation and Configuration Guide Google Enterprise EMEA Google Search Appliance is able to natively crawl secure content coming from multiple sources using for instance the following main
Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat
Programming on the Web(CSC309F) Tutorial: Servlets && Tomcat TA:Wael Aboelsaadat Acknowledgments : This tutorial is based on a series of articles written by James Goodwill about Tomcat && Servlets. 1 Tomcat
A Guide to Understanding Web Application Development Corey Benson, SAS Institute, Inc., Cary, NC Robert Girardin, SAS Institute, Inc.
Paper 024-29 A Guide to Understanding Web Application Development Corey Benson, SAS Institute, Inc., Cary, NC Robert Girardin, SAS Institute, Inc., Cary, NC ABSTRACT You have been asked by your manager
Apache Jakarta Tomcat
Apache Jakarta Tomcat 20041058 Suh, Junho Road Map 1 Tomcat Overview What we need to make more dynamic web documents? Server that supports JSP, ASP, database etc We concentrates on Something that support
Core Java+ J2EE+Struts+Hibernate+Spring
Core Java+ J2EE+Struts+Hibernate+Spring Java technology is a portfolio of products that are based on the power of networks and the idea that the same software should run on many different kinds of systems
How To Understand The Architecture Of Java 2Ee, J2Ee, And J2E (Java) In A Wordpress Blog Post
Understanding Architecture and Framework of J2EE using Web Application Devadrita Dey Sarkar,Anavi jaiswal, Ankur Saxena Amity University,UTTAR PRADESH Sector-125, Noida, UP-201303, India Abstract: This
Case Studies of Running the Platform. NetBeans UML Servlet JSP GlassFish EJB
September Case Studies of Running the Platform NetBeans UML Servlet JSP GlassFish EJB In this project we display in the browser the Hello World, Everyone! message created in the session bean with servlets
Design Approaches of Web Application with Efficient Performance in JAVA
IJCSNS International Journal of Computer Science and Network Security, VOL.11 No.7, July 2011 141 Design Approaches of Web Application with Efficient Performance in JAVA OhSoo Kwon and HyeJa Bang Dept
ACM Crossroads Student Magazine The ACM's First Electronic Publication
Page 1 of 8 ACM Crossroads Student Magazine The ACM's First Electronic Publication Crossroads Home Join the ACM! Search Crossroads [email protected] ACM / Crossroads / Columns / Connector / An Introduction
Supplement IV.E: Tutorial for Tomcat. For Introduction to Java Programming By Y. Daniel Liang
Supplement IV.E: Tutorial for Tomcat For Introduction to Java Programming By Y. Daniel Liang This supplement covers the following topics: Obtaining and Installing Tomcat Starting and Stopping Tomcat Choosing
Model-View-Controller. and. Struts 2
Model-View-Controller and Struts 2 Problem area Mixing application logic and markup is bad practise Harder to change and maintain Error prone Harder to re-use public void doget( HttpServletRequest request,
JBoss Portlet Container. User Guide. Release 2.0
JBoss Portlet Container User Guide Release 2.0 1. Introduction.. 1 1.1. Motivation.. 1 1.2. Audience 1 1.3. Simple Portal: showcasing JBoss Portlet Container.. 1 1.4. Resources. 1 2. Installation. 3 2.1.
Agenda. Summary of Previous Session. Application Servers G22.3033-011. Session 3 - Main Theme Page-Based Application Servers (Part II)
Application Servers G22.3033-011 Session 3 - Main Theme Page-Based Application Servers (Part II) Dr. Jean-Claude Franchitti New York University Computer Science Department Courant Institute of Mathematical
Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1
1 of 11 16.10.2002 11:41 Hello World Portlet Rendered with JSP for WebSphere Portal Version 4.1 Table of Contents Creating the directory structure Creating the Java code Compiling the code Creating the
Web Frameworks and WebWork
Web Frameworks and WebWork Problem area Mixing application logic and markup is bad practise Harder to change and maintain Error prone Harder to re-use public void doget( HttpServletRequest request, HttpServletResponse
Java technológiák 7. előadás A Struts keretrendszer
Java technológiák 7. előadás A Struts keretrendszer Sapientia - EMTE 2010 Struts keretrendszer Bevezető Struts és az MVC tervezési minta Struts Action osztály fejlesztése Struts Action konfigurálása Miért
Developing XML Solutions with JavaServer Pages Technology
Developing XML Solutions with JavaServer Pages Technology XML (extensible Markup Language) is a set of syntax rules and guidelines for defining text-based markup languages. XML languages have a number
Controlling Web Application Behavior
2006 Marty Hall Controlling Web Application Behavior The Deployment Descriptor: web.xml JSP, Servlet, Struts, JSF, AJAX, & Java 5 Training: http://courses.coreservlets.com J2EE Books from Sun Press: http://www.coreservlets.com
SSC - Web development Model-View-Controller for Java web application development
SSC - Web development Model-View-Controller for Java web application development Shan He School for Computational Science University of Birmingham Module 06-19321: SSC Outline Outline of Topics Java Server
CSI 2132 Lab 8. Outline. Web Programming JSP 23/03/2012
CSI 2132 Lab 8 Web Programming JSP 1 Outline Web Applications Model View Controller Architectures for Web Applications Creation of a JSP application using JEE as JDK, Apache Tomcat as Server and Netbeans
Java Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
Getting Started with Web Applications
3 Getting Started with Web Applications A web application is a dynamic extension of a web or application server. There are two types of web applications: Presentation-oriented: A presentation-oriented
Java Web Programming with Eclipse
Java Web Programming with Eclipse David Turner, Ph.D. Department of Computer Science and Engineering California State University San Bernardino Jinsok Chae, Ph.D. Department of Computer Science and Engineering
Server-Side Web Development JSP. Today. Web Servers. Static HTML Directives. Actions Comments Tag Libraries Implicit Objects. Apache.
1 Pages () Lecture #4 2007 Pages () 2 Pages () 3 Pages () Serves resources via HTTP Can be anything that serves data via HTTP Usually a dedicated machine running web server software Can contain modules
Install guide for Websphere 7.0
DOCUMENTATION Install guide for Websphere 7.0 Jahia EE v6.6.1.0 Jahia s next-generation, open source CMS stems from a widely acknowledged vision of enterprise application convergence web, document, search,
Oracle WebLogic Server 11g: Administration Essentials
Oracle University Contact Us: 1.800.529.0165 Oracle WebLogic Server 11g: Administration Essentials Duration: 5 Days What you will learn This Oracle WebLogic Server 11g: Administration Essentials training
Java Web Programming. Student Workbook
Student Workbook Java Web Programming Mike Naseef, Jamie Romero, and Rick Sussenbach Published by ITCourseware, LLC., 7245 South Havana Street, Suite 100, Centennial, CO 80112 Editors: Danielle Hopkins
Client-server 3-tier N-tier
Web Application Design Notes Jeff Offutt http://www.cs.gmu.edu/~offutt/ SWE 642 Software Engineering for the World Wide Web N-Tier Architecture network middleware middleware Client Web Server Application
Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.
Avaya Solution & Interoperability Test Lab Application Notes for Packaging and Deploying Avaya Communications Process Manager Sample SDK Web Application on a JBoss Application Server Issue 1.0 Abstract
Java EE Introduction, Content. Component Architecture: Why and How Java EE: Enterprise Java
Java EE Introduction, Content Component Architecture: Why and How Java EE: Enterprise Java The Three-Tier Model The three -tier architecture allows to maintain state information, to improve performance,
Struts 2 - Practical examples
STRUTS 2 - Practical examples Krystyna Bury Katarzyna Sadowska Joanna Pyc Politechnika Wrocławska Wydział Informatyki i Zarządzania Informatyka, III rok Spis treści What will we need? 1 What will we need?
Simplify Your Web App Development Using the Spring MVC Framework
1 of 10 24/8/2008 23:07 http://www.devx.com Printed from http://www.devx.com/java/article/22134/1954 Simplify Your Web App Development Using the Spring MVC Framework Struts is in fairly widespread use
Oracle WebLogic Server
Oracle WebLogic Server Developing Web Applications, Servlets, and JSPs for Oracle WebLogic Server 10g Release 3 (10.3) July 2008 Oracle WebLogic Server Developing Web Applications, Servlets, and JSPs for
Course Number: IAC-SOFT-WDAD Web Design and Application Development
Course Number: IAC-SOFT-WDAD Web Design and Application Development Session 1 (10 Hours) Client Side Scripting Session 2 (10 Hours) Server Side Scripting - I Session 3 (10 hours) Database Session 4 (10
Web-based IDE for Interfacing View Controller
Web-based IDE for Interfacing View Controller A Writing Project Presented to The Faculty of the Department of Computer Science San José State University In Partial Fulfillment Of the Requirements for the
An Overview of Servlet & JSP Technology
2007 Marty Hall An Overview of Servlet & JSP Technology 2 Customized J2EE Training: http://courses.coreservlets.com/ Servlets, JSP, Struts, JSF, EJB3, Ajax, Java 5, Java 6, etc. Ruby/Rails coming soon.
Ch-03 Web Applications
Ch-03 Web Applications 1. What is ServletContext? a. ServletContext is an interface that defines a set of methods that helps us to communicate with the servlet container. There is one context per "web
Tomcat 5 New Features
Tomcat 5 New Features ApacheCon US 2003 Session MO10 11/17/2003 16:00-17:00 Craig R. McClanahan Senior Staff Engineer Sun Microsystems, Inc. Slides: http://www.apache.org/~craigmcc/ Agenda Introduction
Creating Java EE Applications and Servlets with IntelliJ IDEA
Creating Java EE Applications and Servlets with IntelliJ IDEA In this tutorial you will: 1. Create IntelliJ IDEA project for Java EE application 2. Create Servlet 3. Deploy the application to JBoss server
Crystal Reports for Borland JBuilder
Embedding reports within JBuilder web applications projects Overview Contents With the recent addition of embedded reporting to the JBuilderX feature-set, it is now possible to process and render industry-standard
An introduction to web programming with Java
Chapter 1 An introduction to web programming with Java Objectives Knowledge Objectives (continued) The first page of a shopping cart application The second page of a shopping cart application Components
An Architecture for Web-based DSS
Proceedings of the 6th WSEAS Int. Conf. on Software Engineering, Parallel and Distributed Systems, Corfu Island, Greece, February 16-19, 2007 75 An Architecture for Web-based DSS Huabin Chen a), Xiaodong
Java Web Services Developer Pack. Copyright 2003 David A. Wilson. All rights reserved.
Java Web Services Developer Pack Copyright 2003 David A. Wilson. All rights reserved. Objectives Configure to use JWSDP Find the right sample program Many in JWSDP More in the Web Services Tutorial Find
JSP Java Server Pages
JSP - Java Server Pages JSP Java Server Pages JSP - Java Server Pages Characteristics: A way to create dynamic web pages, Server side processing, Based on Java Technology, Large library base Platform independence
Web Applications and Struts 2
Web Applications and Struts 2 Problem area Problem area Separation of application logic and markup Easier to change and maintain Easier to re use Less error prone Access to functionality to solve routine
Java Server Pages combined with servlets in action. Generals. Java Servlets
Java Server Pages combined with servlets in action We want to create a small web application (library), that illustrates the usage of JavaServer Pages combined with Java Servlets. We use the JavaServer
Japan Communication India Skill Development Center
Japan Communication India Skill Development Center Java Application System Developer Course Detail Track 2b Java Application Software Developer: Phase1 SQL Overview 70 Introduction Database, DB Server
DeskNow. Ventia Pty. Ltd. Advanced setup. Version : 3.2 Date : 4 January 2007
Ventia Pty. Ltd. DeskNow Advanced setup Version : 3.2 Date : 4 January 2007 Ventia Pty Limited A.C.N. 090 873 662 Web : http://www.desknow.com Email : [email protected] Overview DeskNow is a computing platform
Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat
Client-Server Architecture & J2EE Platform Technologies Overview Ahmed K. Ezzat Page 1 of 14 Roadmap Client-Server Architecture Introduction Two-tier Architecture Three-tier Architecture The MVC Architecture
Web Application Programmer's Guide
Web Application Programmer's Guide JOnAS Team ( Florent BENOIT) - March 2009 - Copyright OW2 consortium 2008-2009 This work is licensed under the Creative Commons Attribution-ShareAlike License. To view
IBM WebSphere Server Administration
IBM WebSphere Server Administration This course teaches the administration and deployment of web applications in the IBM WebSphere Application Server. Duration 24 hours Course Objectives Upon completion
2. Follow the installation directions and install the server on ccc
Installing a Web Server 1. Install a sample web server, which supports Servlets/JSPs. A light weight web server is Apache Tomcat server. You can get the server from http://tomcat.apache.org/ 2. Follow
Japan Communication India Skill Development Center
Japan Communication India Skill Development Center Java Application System Developer Course Detail Track 2a Java Application Software Developer: Phase1 SQL Overview 70 Introduction Database, DB Server
High Level Design Distributed Network Traffic Controller
High Level Design Distributed Network Traffic Controller Revision Number: 1.0 Last date of revision: 2/2/05 22c:198 Johnson, Chadwick Hugh Change Record Revision Date Author Changes 1 Contents 1. Introduction
Web Applications. For live Java training, please see training courses at
2009 Marty Hall Using and Deploying Web Applications Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/msajsp.html Customized Java EE Training: http://courses.coreservlets.com/
Pentesting Web Frameworks (preview of next year's SEC642 update)
Pentesting Web Frameworks (preview of next year's SEC642 update) Justin Searle Managing Partner UtiliSec Certified Instructor SANS Institute [email protected] // @meeas What Are Web Frameworks Frameworks
Japan Communication India Skill Development Center
Japan Communication India Skill Development Center Java Application System Developer Course Detail Track 3 Java Application Software Developer: Phase1 SQL Overview 70 Querying & Updating Data (Review)
Java and Web. WebWork
Java and Web WebWork Client/Server server client request HTTP response Inside the Server (1) HTTP requests Functionality for communicating with clients using HTTP CSS Stat. page Dyn. page Dyn. page Our
Web Programming II JSP (Java Server Pages) ASP request processing. The Problem. The Problem. Enterprise Application Development using J2EE
Enterprise Application Development using J2EE Shmulik London Lecture #6 Web Programming II JSP (Java Server Pages) How we approached it in the old days (ASP) Multiplication Table Multiplication
Web Development on the SOEN 6011 Server
Web Development on the SOEN 6011 Server Stephen Barret October 30, 2007 Introduction Systems structured around Fowler s patterns of Enterprise Application Architecture (EAA) require a multi-tiered environment
Server Setup and Configuration
Server Setup and Configuration 1 Agenda Configuring the server Configuring your development environment Testing the setup Basic server HTML/JSP Servlets 2 1 Server Setup and Configuration 1. Download and
Customer Bank Account Management System Technical Specification Document
Customer Bank Account Management System Technical Specification Document Technical Specification Document Page 1 of 15 Table of Contents Contents 1 Introduction 3 2 Design Overview 4 3 Topology Diagram.6
Performance Comparison of Persistence Frameworks
Performance Comparison of Persistence Frameworks Sabu M. Thampi * Asst. Prof., Department of CSE L.B.S College of Engineering Kasaragod-671542 Kerala, India [email protected] Ashwin A.K S8, Department
Efficiency of Web Based SAX XML Distributed Processing
Efficiency of Web Based SAX XML Distributed Processing R. Eggen Computer and Information Sciences Department University of North Florida Jacksonville, FL, USA A. Basic Computer and Information Sciences
Web-JISIS Reference Manual
23 March 2015 Author: Jean-Claude Dauphin [email protected] I. Web J-ISIS Architecture Web-JISIS Reference Manual Web-JISIS is a Rich Internet Application (RIA) whose goal is to develop a web top application
Reporting and JSF. Possibilities, solutions, challenges. Slide 1. Copyright 2009, Andy Bosch, www.jsf-portlets.net
Reporting and JSF Possibilities, solutions, challenges Slide 1 Agenda What is reporting? Why do we need it? The JSF example application Introduction to reporting engines Overview Eclipse BIRT JasperReports
WebSphere Server Administration Course
WebSphere Server Administration Course Chapter 1. Java EE and WebSphere Overview Goals of Enterprise Applications What is Java? What is Java EE? The Java EE Specifications Role of Application Server What
How to Build an E-Commerce Application using J2EE. Carol McDonald Code Camp Engineer
How to Build an E-Commerce Application using J2EE Carol McDonald Code Camp Engineer Code Camp Agenda J2EE & Blueprints Application Architecture and J2EE Blueprints E-Commerce Application Design Enterprise
