29.01.2013 Views

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

WebSphere Application Server - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Important: If you use the Struts framework for this function of your<br />

application, you have to apply it to all the pages added thereafter.<br />

For example, you cannot hyperlink the menu functions of either the admin1.jsp<br />

or admin2.jsp pages to other pages. You would have to create an action for<br />

each forward. If you are forwarding for forms, you would be required to create<br />

form beans to capture the data and then create an action to perform any logic.<br />

This would be done in the same fashion as was illustrated above.<br />

1. From the Project Navigator view of the Web perspective, navigate to Web Site<br />

Configuration and double-click it to open the Web site diagram for the<br />

application.<br />

2. With the diagram open, locate the login.jsp page, drag it from the Project<br />

Navigator view and drop it behind the index.html page to create a child of the<br />

index.html page.<br />

3. To apply the template, select Page Template -> Apply Template... from the<br />

context menu.<br />

4. Disable the Navigation Candidate property by right-clicking the pages and<br />

selecting Navigation -> Navigation Candidate from the context menu. If you<br />

do not do this, all of the pages will appear in the site navigation.<br />

5. Add admin1.jsp and admin2.jsp. to the Web Site Configuration and apply the<br />

template.<br />

6. Save the Web site diagram.<br />

12.3.11 Understanding the Struts configuration file<br />

Up to this point, you have created Web pages, action forms and action classes to<br />

implement the site administration login process. As you created these<br />

components, Studio Site Developer internally modified the Struts configuration<br />

file.<br />

Navigate to the struts-config.xml file in the WEB-INF of the project and<br />

double-click it to open the editor. Click the Source tab and take a look at the tags<br />

in the file to understand how the various components work together within the<br />

Struts framework.<br />

During runtime, when the user enters the username and password in the<br />

login.jsp page and submits it, the following occurs:<br />

1. The ActionServlet forwards the user input to the form class represented by<br />

loginForm to validate the user input. The loginForm class and login.jsp should<br />

452 <strong>IBM</strong> <strong>WebSphere</strong> <strong>Application</strong> <strong>Server</strong> - Express V5.0.2 Developer Handbook

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!