 | Level: Intermediate Clifford Spinac (spinac@us.ibm.com), Senior e-business architect, IBM
26 Jun 2003 This article shows how to use IBM's WebSphere Studio products to create a simple Web application using Struts, a conceptual framework for developing Web applications that is part of the Apache Software Foundation Jakarta project. For questions, comments, or help, visit our tech support discussion forum.
Introduction
Struts is a conceptual framework for developing Web applications.
It is a variation of the Model-View-Controller (MVC) design paradigm in which a Controller function mediates between the application logic (the Model) and the presentation of the data (the View). The framework contains a set of Java classes and JSP tag libraries. Together with the tools in IBM WebSphere Studio, Struts helps developers design and implement their Web applications rapidly.
Struts is one of the many products of the Apache Software Foundation Jakarta project.
This article shows you how to use IBM WebSphere Studio Site Developer to create the initial components needed for a Struts-based Web application. These components include the following:
- The entry page of the application’s Web site (index.jsp), which contains a login form for entry of a userid and password
- An associated
ActionForm class for initial data validation, which verifies that the user has entered a user id and password and issues an error message if not
- An
Action class to authenticate the user’s user id and password (in a real application, security -- such as userid/password authorization -- should be managed by WebSphere or IBM Policy Director)
- The Web site’s home.jsp, which will be invoked upon successful login
- An error.jsp page, which will be displayed if the entered userid and password cannot be authenticated
Figure 1. Sample Struts application
Before you begin
Install Red
Hat Linux 7.2, Red Hat Linux 7.3, SuSE Linux 7.3, or SuSE Linux Enterprise Server (SLES) 8.
You will need WebSphere Studio Site Developer. You can get a free 60-day trial edition either by ordering a free set of CDs containing this and other IBM trial software, or you can download it.
Information on ordering the CD set or downloading products is on the "Speed-start your Linux application" overview page.
Although our examples in this article use IBM WebSphere Studio Site Developer, you may also use IBM WebSphere Studio Application Developer, which includes additional features, such as EJB support. We'll refer to either as "WebSphere Studio" from here on in this article.
You should use the Help->Software Updates menu function to update your WebSphere Studio software to the 5.0.1 level. This will correct some interface problems that we will mention below; otherwise, these problems would require you to stop and restart WebSphere Studio.
New to Linux? If you're new to Linux and need help with logging in and out, mounting a CD-ROM, or opening a terminal window, see the
"Basic
tasks for new Linux developers", which covers these tasks and more.
Create a Web project
In this section, we will log in, start WebSphere Studio, and create a Web project for our Struts application in a new workspace.
-
Log in as a user (not the root user) and start WebSphere Studio Site Developer.
Run wssitedev50 from a terminal window.
If /usr/bin is not in your path, run /usr/bin/wssitedev50.
You can also start programs from the taskbar on your
desktop. For example, with KDE, select Start Application > Run Command...
and type in wssitedev50 or /usr/bin/wssitedev50 as appropriate.
For this example, we'll create a new workspace called MyBank to keep this project
separate from other work you may be doing.
Figure 2. Starting a new project
-
You will see the Site Developer logo displayed while the workspace is being created.
Please be patient as this may take some time.
Figure 3. Creating the MyBank workspace
-
When the workspace opens, your first task is to create a new project. For this project, we'll introduce you to the Struts-based Web application cheat sheet. For other methods of creating a project, see the article "Hello, World in 90 seconds with WebSphere Studio Site Developer V5". We'll point out things that the cheat sheet does for you along the way, and we'll illustrate some things that the cheat sheet doesn't cover. To start a new Struts project with a cheat sheet, click Help > Cheat Sheets > Create a Struts-based Web application, as shown in Figure 4.
Figure 4. Creating a new project
-
The cheat sheet introduction opens. You now have a cheat sheet icon in the left navigation area that you
may use to open the cheat sheet when it is not visible.There is also a button in the shape of a black arrow
that you will use to advance through the cheat sheet. Click it now to move to the next stage of the cheat sheet where we will start creating our project.
Figure 5. Cheat sheet introduction
-
Click the perform button (black arrow) to create a Web project.
Figure 6. Cheat sheet -- Create a Web project
-
On the next screen, enter MyBankWeb for the Project name. The cheat sheet
has selected Add Struts support under Web Project features.
The option to Create a default CSS file should be selected already. Click Next.
Figure 7. Creating a new Web project
-
On the J2EE Settings Page, enter MyBankEAR for the New project name
and MyBank for the Context root. Use the default J2EE level 1.3. Click Next.
Figure 8. Specifying J2EE settings
-
On the Struts Settings window, the defaults are acceptable. Note that
Create a Resource Bundle for Struts Project is checked. In the next part of the process, we will
add screen text and error message properties to this Resource bundle. Keeping strings like this in a
resource bundle helps with translating our Web page to another language.
Click Finish.
Figure 9. Specifying struts settings
-
You will return to the cheat sheet with one more item checked. Click the Minimize (_) button on
the cheat as we will be using some other features of the workspace in the next step.
Figure 10. Cheat sheet -- Create a Web diagram
 |
Perspectives in WebSphere Studio
Before we continue, we need to cover an important concept. WebSphere Studio is a task-oriented tool whose user interfaces are customized for the task being performed.
The interface used for developing a JSP is much different from the one for Server development. Site Developer lets you control what windows and views you see by switching the perspective
you are using.
A perspective is a set of views that show the resources you need when performing a specific task.
WebSphere Studio has perspectives defined for Web application development, J2EE development, debugging,
and many other common tasks.
The left navigation bar contains several icons that allow you to easily open or switch between perspectives.
|
- Open a perspective
- Opens a new perspective or switches to one already open. Common perspectives are
listed in the menu and many additional ones are accessible through the Other menu
choice.
|
|
- Web perspective
- Switches the view to the web perspective.
|
|
- Cheat sheets
- Displays or minimizes the cheat sheet
|
Application resources
We mentioned above that we would create a resource bundle to allow text to be translated. According to the initial design
of this application, it will have three JavaServer Pages: index.jsp, home.jsp, and error.jsp.
We will show you how to create application resources for the title to be used on all of our pages, the error messages,
the button text, and userid and password prompts. Although we would not mix different approaches in a real application, we will also edit some text directly into the pages so you can see the different ways of working.
These resources are stored in the application resources properties file.
In this section we'll show you a few more tips about the IDE and then create these application resources.
-
If you've followed along, you should be looking at the Web perspective. If not, then click the
Web perspective icon in the left navigation bar (as described
in Perspectives in WebSphere Studio above), or
select Window > Open Perspective > Web. We'll use the J2EE navigator pane in the
Web perspective to navigate to the application resources file and then open it for editing.
The tabs at the bottom of the pane allow you to switch between panes.
Figure 11. The J2EE Navigator pane
-
Now expand the Web project tree by clicking on the plus (+) signs to display the
ApplicationResources.properties file as shown in Figure 12.
If the J2EE pane is very small, you can press the right mouse button on the title to bring up the context menu and then maximize the pane.
Figure 12. The expanded J2EE Navigator pane
-
Double click ApplicationResources.properties
in MyBankWeb.Web Content.WEB-INF.classes.mybankweb.resources, to open it with the Properties File Editor.
Notice how the J2EE navigator pane is restored to its previous size when you do this.
Although beyond the scope of this article, you can use other editors if you wish.
Select Window > Preferences and look under File associations in the Workbench section
of the preferences tree.
Remove the # in the front of the errors.header and errors.footer properties. After the errors.footer property, add the lines shown in the listing below.
Hint: Applications on Linux sometimes, but not always, share a clipboard. In this case, Edit > copy (ctrl-C) and Edit > paste (ctrl-V) usually work for copy and paste. If that doesn't work,
an older method is often available if you have a three-button mouse (or if you have set up your mouse to emulate three buttons by chording both buttons -- that is, holding down both together).
Hold down your left button and drag over text in one window and then use the middle button (or
chord both buttons on a 2-button mouse) to paste the highlighted text into the the editor pane.
You can use this handy trick within a window or between windows.
Listing 1. Add these lines after the errors.footer property in the ApplicationResources.properties file
# Optional header and footer for <errors/> tag.
errors.header=<ul>
errors.footer=</ul>
index.title=MyBank Application
button.login=Login
global.field.userid=User ID
global.field.password=Password
error.login.nouserid=<li>You must enter a User ID.
error.login.nopassword=<li>You must enter a Password.
error.login.failed=<li>Invalid User ID and/or Password entered.
error.login.exception=<li>Exception occurred in action. |
- The values you just added will represent the display output in your JSP files. Note that our
error messages will be displayed as list elements in an unordered list.
Save and close the ApplicationResources.properties file.
In the default editor, you can use keyboard shortcuts if you prefer: Ctrl-s will save the file, and Ctrl-F4 will close the pane.
 |
Struts application diagram
In this step we'll return to the cheat sheet and create a Struts application diagram,
which we will use to design and build our application’s components.
- Click on the cheat sheet icon in the left navigation bar to restore the cheat sheet as it was
in Figure 10. Click on the Perform button to create a new Web diagram.
If you are not using a cheat sheet, you can open the New wizard by clicking the toolbar button
( )
(or select File > New > Other.... ).
On the left pane of the Select dialog, expand Web and select Struts.
Select Web Diagram in the right pane. Click Next.
Note: If you prefer not to use a Struts application diagram, you can still create each of the components
for this project by using the new file wizards that are available under File > New > Other... , and selecting
Web > Struts and the component you wish to build.
- Enter Login for the File name. Click Finish.
Figure 13. Create a new Web diagram
The Struts application diagram file Login.gpf is created and opens with SADE (Struts application diagram editor).
You will now lay out your JavaServer Pages, Form Bean, and Action Bean on the Free Form Surface (FFS).
We will use the following buttons from the toolbar above the editor. (These buttons will be greyed out until you move the mouse over them.)
|
- Connection
- Draws a connection from the selected node to a target
|
|
- Action Mapping Node
- Primes the cursor ready to drop a new action mapping onto the FFS
|
|
- Form Bean Node
- Primes the cursor ready to drop a new form bean node onto the FFS
|
|
- Java Bean Node
- Primes the cursor ready to drop a new java bean node onto the FFS
|
|
- Web Page Node
- Primes the cursor ready to drop a new Web page onto the FFS
|
- We will now create the Web Page objects. First, click the New Web Page Node
button (
) in the
toolbar (or right click in the diagram editor surface and select New > Web Page Node), then click
on the left side of the diagram editor to drop the Web Page Node. Change the path of the page from the default
of /page.jsp to /index.jsp and then press Enter. Right click on your new JSP
to bring up the context menu and
select Change description. Enter a description of Login entry page and press Enter.
Your FFS should now look something like Figure 14. If you made a mistake in the path or description, you can
change them using the context menu.
Figure 14. Create a new JSP
- In the same way, create two more New Web Page Nodes on the FFS and change their path names
to /home.jsp and /error.jsp, as shown in Figure 15. You may add descriptions if you would like.
Figure 15. Create additional JSPs
- In a similar manner, place an Action Mapping Node
(
) in the middle
of the FFS and set its path to /login. Then create a Form Bean object
( ). In the Form Bean Attributes,
enter loginForm for the Name and leave the scope as request. Click OK.
Figure 16. Create a form bean
- Now we'll create the connections between the nodes. A Struts diagram connection is a line that represents
either logic flow or data flow between two Struts nodes. To create a connection, click the Connect Two Nodes
button (
) in the toolbar.
Click the source object first and then the target object to create the connection between the two nodes
in the editor.
- Connect the index.jsp (Login entry) page to the login action mapping.
- Connect the login action mapping to the home.jsp page. Replace the forward name for the
connection <new> with success, and press Enter. If you need to
change the connection forward name later, just right click the connection line and select
Edit the forward name.
- Connect the login action mapping to the error.jsp page.
Replace the forward name for the connection
<new> with failure, and press Enter.
- Connect the error.jsp page to the index.jsp (Login entry) page.
- Connect the index.jsp (Login entry) page to the loginForm Bean.
After making these connections you should have a layout similar to Figure 17.
Figure 17. Adding connections
Notice that the objects are grey and the connections are dashed lines because they have not been
implemented yet (they are unrealized).
 |
Implement the JavaServer Pages
Now we will return to the cheat sheet to implement (or realize) our JSPs: the index.jsp
(Login entry page), the home page, and the error page.
- Display the cheat sheet again and click the Perform button in the
section Create the JSPs (WebPages) and Beans.
On the resulting window, expand MyBankWeb and click
once to select the Login form and then click OK.
A new window will open with a checklist of unrealized JSPs and form beans. We'll start with the index.jsp, so
select it and click OK (or just double-click).
Figure 18. List of unrealized JSPs and beans
- We will now use the Page Designer to create the index.jsp.
- The new JSP wizard should be open. If you were not using a cheat sheet, you could also open this
wizard by double-clicking on the index.jsp node in the application diagram (Login.gph).
The File Name will already be set to index, and the Model will be set to Struts JSP.
Click Finish.
Figure 19. The new JSP wizard
- The Page Designer will start in Design mode. Before we start editing our JSP, we'll introduce you to
a few more handy views in the Studio IDE. From the tabs below the bottom left pane of the IDE (Gallery,
Library, Outline, ...) click the Outline tab to select the outline view, which will give us a tree-structured
outline view of our JSP that will help us ensure that our page structure is correct.
The bottom right pane contains a message indicating that the /login target does not exist. We will need
to edit several properties, so we will open the properties view here. To do this, select
Window > Show View > Other. On the resulting dialog, expand Basic, select
Properties, and click OK. A Properties tab will be added to the lower
right pane, and the pane will be open in the Properties view. Your screen should now look like Figure 20.
Figure 20. Outline and properties views
- Now we'll return to creating our JSP. There will already be a <html:form> tag set
(denoted by an outlined box), with the action set to /login to invoke the login action mapping.
Click within the outlined box to select it. You will see the outline of the box change when it
is selected. The html:form element should also be selected in the outline view.
Once it's selected, click on the JSP menu and select Insert Custom.
Figure 21. Page design
- Select bean and message as shown in Figure 22. Click Insert.
Select html and text, and click Insert again. Then click Close.
This will insert a message bean for the userid prompt
and a text field for the user to enter the id. Notice the extra items in the outline view.
Figure 22. Adding message bean and text field
- The message bean custom tag that you inserted in the login form in the previous step should have text
saying Missing message for key. Click this bean:message custom tag to select it (or select it in the outline view).
This should display the bean's properties in the properties view.
If your properties view is very small, you may want to enlarge it by dragging the top of it
upward using
the left mouse button as we've done in Figure 23. Scroll down the Properties view and change the
message’s key property to global.field.userid. Press Enter. This will use the text
associated with global.field.userid in the application resource file.
In the same way, select the html:text custom tag you inserted and change its property property
to userid. This will be the name in our Java code of the variable for the userid.
Depending on the speed of your processor and the amount of RAM you
have, there may be some delays while you change properties.
Figure 23. Setting message bean key property
- Position the cursor after the html:text field and press Enter to insert a line break (BR).
We will now insert two more custom elements to create our password prompt and entry field,
so click on the JSP menu and select Insert Custom.
Select bean and message and click Insert.
Select html and password and click Insert to add a password entry field. Click Close.
Set the key property for the new message bean to global.field.password and press
Enter. Set the property property to password and press Enter.
Your screen should look something like Figure 24.
Figure 24. Adding password prompt and entry fields
- Now that our data entry fields are defined, we need a button to submit the form. Position the cursor
after the html:password field and press Enter twice to insert two line breaks. Now use the JSP menu
and select Insert Custom. This time, select html and Submit and click Insert, then
select bean and message, and click Insert again. Click
Close. In the Properties view,
enter button.login for the key property of the new message bean and press Enter.
(If you have not run Help > Software updates to upgrade to version 5.0.1, the button.login text may not
appear immediately in the Design view). If all is well, your screen should now look like Figure 25.
Figure 25. Adding the submit button
- Click above the form (outside of it) to add a heading tag. Your cursor should be positioned right before
your form. The outline should have "BODY" highlighted.
From the menu bar, select Format > Paragraph > Heading 1.
Add the Login page heading text by inserting another bean:message JSP Custom Tag. Set the key
property to index.title and press Enter. The MyBank Application header should appear.
Figure 26. Adding a page heading
- Click between the heading and the form. Then insert another JSP Custom tag
html:errors.
Figure 27. Adding html:errors tag
- We can view the source for our page by clicking the Source tab. The Source view of the
Login entry page is shown in Figure 28. Note that the action /login has a warning beside it because we have
not yet defined an action mapping for it.
Figure 28. The source view
- Use File > Save index.jsp then File > Close to save and close your JSP.
Note that the index.jsp node in the application diagram is now colored, indicating that it is realized.
We also have a check mark in the cheat sheet's list of JSPs and beans.
- Now that the Login entry page (index.jsp) is created, you can create the home.jsp page for the Web site.
- Either select the home.jsp entry in the cheat sheet list of JSPs and beans, and click OK
as you did in the previous step for the index.jsp node, or double-click on the home.jsp node
in the application diagram (Login.gph). This will start the New JSP File wizard.
The File Name will already be set to home.jsp, and the Model will be set to Struts JSP.
Click Finish.
- Switch to the Page Designer’s Source view, and delete the text
<P> Place home.jsp’s content here.</P>. Replace it with these lines to implement the home page:
(To save time you can copy/paste the code below.)
<h1><bean:message key="index.title"/></h1>
<h2>Welcome <bean:write name="loginForm" property="userid"/></h2>
<h2>To MyBank Home Page</h2> |
Notice that the home page is using the loginForm’s userid bean property to output the User ID input.
Think about how you would add the bean:write in Design view. Notice also that the H2 element
is not using text from the application resource file, but is using static text. As we said earlier, we are illustrating
both methods here, but it is not good practice to mix text sources in this way.
- Switch to Design view to see how your page looks. Then save and close home.jsp.
- With the index.jsp and home.jsp pages now created, you can create the error.jsp page.
- In the application diagram (Login.gph), double-click the error.jsp node as you did in the previous
step for the index.jsp node. This will start the New JSP File wizard.
The File Name of the Model will be set already. Click Finish.
- In the Page Designer’s Source view, delete the text
<P> Place home.jsp’s content here.</P>. Replace it with these lines to implement the error page:
(To save time you can copy/paste the code below.)
<h1><bean:message key="index.title"/></h1>
<h2>Error Page</h2>
<p>
<html:errors/>
<p>
<a href="index.jsp"><b>Return to Login Page</b></a> |
- Switch to the Design view to see how your page looks. Then save and close home.jsp.
- At this point your application diagram should have all three JSP pages colored.
Figure 29. Application diagram with realized JSPs
 |
Implement the ActionForm class
- Now you need to implement the
loginForm class to handle the input from the index.jsp.
This ActionForm class will contain a field and accessors (getters and setters) for each field in the input form,
and will provide simple field checking.
To help with this implementation, you will use the New ActionForm Class wizard.
When the ActionForm class is created, you will then add code to the validate method within your class.
- In the application diagram (Login.gph), double-click the loginForm node.
This will start the New ActionForm Class wizard. The
ActionForm class name will already be set to LoginForm.
Click Next.
If the Next button is obscured by your taskbar, you may have to minimize your taskbar or drag it to a different side of the screen.
Figure 30. Starting the ActionForm wizard
- On "Choose new accessors for your ActionForm class", expand MyBankWeb, Web Pages, index.jsp, and /login.
To Choose Accessors, select text:userid and password:password. Click Next.
(Note: If you do not see text:userid and password:password, you may need to shut down WebSphere Studio, and then restart it.)
Figure 31. Selecting the accessors
- The next page shows the selected New Accessors. Click Next.
- The next page creates the mapping for your
ActionForm class.
Check that the Configuration File Name is WEB-INF/struts-config.xml and the Mapping Name is
loginForm. Click Finish.
Figure 32.Config file and mapping name
- The Java editor will now open on LoginForm.java.
Notice that the wizard has created most of the
ActionForm class for you, including the two fields (userid
and password) and their setter and getter methods.
Scroll the file down to the ActionErrors validate method, near the bottom of the source file,
and replace the method with the code below.
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
// Validate the fields in your form,
// adding each error to this.errors as found
if ((getUserid() == null) || (getUserid().length() == 0))
errors.add("userid",
new ActionError("error.login.nouserid"));
if ((getPassword() == null) || (getPassword().length() == 0))
errors.add("password",
new ActionError("error.login.nopassword"));
return errors;
} |
- Save and close LoginForm.java.
(If you had to minimize your taskbar or move it out of the way, you may restore it now.)
- At this point, you can optionally examine the Struts configuration file.
In the J2EE Navigator view, double-click struts-config.xml in the Web Content/WEB-INF/ directory,
to open it with the Struts Configuration File Editor.
Select the Form Beans tab and select the Bean Name loginForm.
After reviewing the configuration file, close it.
Figure 33. Examining the Struts configuration file
- Close the cheat sheet's list of JSPs and beans.
 |
Implement the Action Mapping and Action Class
Our final piece of realization is to implement the login action mapping and the LoginAction class.
The LoginAction class will be invoked with the data from the login form.
This class can be used to implement the calls to the business logic, as a wrapper class.
It can also be used to make sure that the state and conditions are right for invoking the business logic.
In this exercise, it will be used to verify the user’s authorization by checking the User ID and Password.
To validate the User ID and Password, you would normally use LTPA with an authorization LDAP directory,
such as IBM Directory, or some other authorization management support, such as IBM Policy Director.
In this example, you will just check the User ID and Password against a fixed User ID and Password (userid / password).
- Display the cheat sheet. You should be viewing
the Create the actions section. Click the Perform button to open a list of unrealized actions.
- As you did above for the JSPs and beans, select the unrealized action and click OK.
This will open the New Action Mapping wizard to create our action mapping and action class. If you
are not using a cheat sheet, double-click the login Action Mapping node in the application
diagram (Login.gph). The New Action Mapping wizard will start.
The Configuration File Name will already be set to WEB-INF/struts-config.xml,
the Mapping Path to /login, and Forwards to the Names you defined (success
and failure).
From the Form Bean Name pull-down, select loginForm.
From the Form Bean Scope pull-down, select request. Click Next.
Figure 34. New Action Mapping wizard
- On "Create an Action class for your mapping", the Action class name will already be set to LoginAction.
Click Finish. We won't need the cheat sheet's list of actions any more, so click Close on that.
- The Java editor will open with the
LoginAction class file.
Scroll down to the perform method and replace it with the code below.
public ActionForward perform(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();
// return value
LoginForm loginForm = (LoginForm) form;
try {
// do something here
if (!loginForm.getUserid().equals("userid")
|| !loginForm.getPassword().equals("password"))
errors.add("login", new ActionError("error.login.failed"));
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("login", new ActionError("error.login.exception"));
}
// If a message is required, save the specified key(s)
// into the request for use by the <struts:errors> tag.
if (!errors.empty()) {
saveErrors(request, errors);
// Forward control to the failure URI
forward = mapping.findForward("failure");
} else {
// Forward control to the success URI
forward = mapping.findForward("success");
}
// Finish with
return (forward);
} |
- Save and close LoginAction.java.
Now that all of the components have been implemented, the components on the Login.gph are shown in color.
Figure 35. Everything realized in the application diagram
- Now that the
LoginAction class has been implemented, you can examine the Struts configuration
file to see the changes that the Diagram Editor and the wizards have made.
- In the J2EE Navigator view, double-click struts-config.xml in the
Web Content/WEB-INF/ directory, to open it in the Struts Configuration File Editor.
- Select the Actions tab. Then select the /login Action Path. If it is not set already,
enter /index.jsp for Input. The Specify Forwards fields should be filled in with the Forward Names
that you selected with the JSP pages that are associated with them (success to /home.jsp and failure to /error.jsp).
Figure 36. Setting the action input
- Now examine the XML source for the struts-config.xml file by selecting the XML Source tab.
- Save and close the struts-config.xml file.
 |
Test the Struts application
Now that you have completed the Struts application, you can test it with the built-in WebSphere v5.0 Test Environment.
- Display the cheat sheet again. You should be viewing the section to Run the Web Application.
Click the perform button (black arrow). If you are not using the cheat sheet, you can select index.jsp in the
J2EE Navigator pane. Then right-click index.jsp, and select Run on Server ....
- In the server selection dialog, select WebSphere V5.0 Test Environment and click OK.
Figure 37. Setting the action input
- The project will be published to the Test Environment server. The Server will start and the Console view will open.
When the Server is ready, the Console will display a message ending in "Server server1 open for e-business",
followed by another message ending in
/index.jsp: init.
Figure 38. Server test environment startup
Note: It will be easier to view the console if you close the completed cheat sheet at this point.
- The index.jsp will then open in the Web browser. Enter the User ID userid and Password password.
Click Login.
Figure 39. Logging in
- After a moment, the application will display the .jsp page:
Figure 40. MyBank home page
- Click your browser's Back button and try entering a different User ID or Password, to see the error page.
Click Login.
Figure 41. Error page
- The index.jsp will then open in the Web browser. Enter the User ID userid and Password password.
Click Login.
Figure 42. Missing userid or password
 |
Conclusion
Congratulations! You have just created a Struts-based Web application. You used WebSphere Studio to build the
JavaServer Pages, an ActionForm, an Action class, and the Action Mapping.
You used the Struts Application Diagram Editor to design and create your application.
You then tested your application with the WebSphere v5.0 Test Environment, which is included with WebSphere Studio.
If you have any questions, check out our tech support discussion forum.
Acknowledgment
I would like to thank Ian Shields for adding material for the Struts cheat sheet, adding usage tips on the WebSphere Studio IDE, and making many other modifications as the result of extensive testing.
Resources
- For questions, comments, or help, visit our tech support discussion forum.
- For help with installing Linux, choose the article that matches your
system: "Tips for installing
Red Hat Linux 7.2", "Tips
for installing SuSE Linux 7.3", or
"Installing and configuring
SuSE Linux Enterprise Server (SLES) 8".
- If you are new to Linux, check out our
"Basic
tasks for new Linux developers".
-
Visit the Struts page of the Apache
Jakarta Project for additional information on Struts.
- Take the tutorial "Go-ForIt Chronicles, Part 19: Struttin' your stuff with WebSphere Studio".
- Visit the WebSphere Studio home page.
- The WebSphere Studio
Zone has additional resources for developers using WebSphere Studio.
- Take advantage of the WebSphere Studio Trial support, FAQs, and more in the
WebSphere Studio Trial Program.
- The WebSphere
Download Evaluation Center gives you access to no-charge trial and entry editions of WebSphere
products, along with basic how-to and service information for WebSphere Studio and other products
in the WebSphere family.
- To integrate your data with DB2, WebSphere MQ, and WebSphere Studio Application Developer using XML
as a data interchange medium, take the
tutorial "DB2 and WebSphere MQ integration, Part 1". This first tutorial focuses on installing and configuring the products. Then, to learn how to use the products in a hands-on scenario, take the follow-on tutorial "DB2
and WebSphere MQ integration, Part 2".
- Learn how to integrate the Struts framework with Web services and how to use Struts components to provide and subscribe to a Web service in "Architect
Struts applications for Web services" (developerWorks, April 2003).
- For other IBM application and Web development tools, including Rational products, COBOL, C, and C++ compilers,
visit the IBM Application
and Web Development tools site.
- Return to Speed-start your Linux app for additional resources.
About the author  | |  |
Clifford Spinac is a Senior e-business architect in the IBM Developer Relations organization in Austin, Texas. He has held various software development, design, and planning positions in his 23-year career with IBM and has over 50 patent filings. During the past three years, he has worked in technical consulting on IBM
WebSphere Application Server, WebSphere Commerce Suite, and Linux middleware with software developers and Web integrators. You can contact Cliff at spinac-at-us.ibm.com. |
Rate this page
|  |