06 - MVC with Struts (Logon Example)

06 - MVC with Struts (Logon Example) - CSE 135 MVC with...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CSE 135 MVC with Struts Logon Example Example The example implements a dummy logon functionality – Do not consider this example to be the best way to implement authorization and access control – The example is used only to demonstrate the Struts framework – Appropriate authorization and access control will be covered in a separate lecture shortly 2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 WorkFlow welcome Welcome do Start !validate Welcome.do Logon.do LogonSubmit.do logonForm forward Sign out success Welcome.jsp Sign in (hyperlink) Logon.jsp forward success Submit (button) 3 (hyperlink) Logoff.do WorkFlow welcome Welcome do Start get !validate Welcome.do Logon.do LogonSubmit.do logonForm forward Sign out success Welcome.jsp Sign in (hyperlink) Logon.jsp forward success Submit (button) 4 Session Scope user: logonForm UserDirectory isValidPassword(String username, String password) set remove (hyperlink) Logoff.do
Background image of page 2
3 Welcome.do 5 Logon.do 6
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 LogonSubmit.do (no password) 7 LogonSubmit.do (wrong pasword) 8
Background image of page 4
5 LogonSubmit.do (success) 9 Logoff.do 10
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 /index.jsp <%@ taglib uri="http://struts.apache.org/tags logic" prefix="logic" %> <logic:redirec forward="welcome"/> <logic:redirect forward= welcome /> <% ‐‐ Redirect default requests to Welcome global ActionForward. ‐‐ %> 11 /pages/Welcome.jsp <%@ taglib uri="http://struts.apache.org/tags bean" prefix="bean" %> <%@ taglib uri="http://struts.apache.org/tags html" prefix="html" %> <%@ taglib uri="http://struts.apache.org/tags logic" prefix="logic" %> <html:html> <head> <title> <bean:message key="app.title" /> </title> <html:base /> </head> <body> 12 <logic:present name="user"> <h3>Welcome <bean:write name="user" property="username" /> !</h3> </logic:present>
Background image of page 6
7 /pages/Welcome.jsp (cont’d) ... <logic:notPresent scope="session" name="user"> <h3><bean:message key="welcome.heading" /></h3> </logic:notPresent> <html:errors /> <ul> <li> <html:link forward="logon"> Sign in </html:link> </li> <logic:present name="user"> 13 <logic:present name user > <li><html:link forward="logoff">Sign out</html:link></li> </logic:present> </ul> </body> </html:html> Edge Labels In struts-config.xml <! ‐‐ =========Global Forward Definitions <global forwards> <forward name=" logoff " path="/Logoff.do"/> <forward name=" logon " path="/Logon.do"/> <forward 14 name=" welcome " path="/Welcome.do"/> </global forwards>
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 /pages/Logon.jsp <body> <html:errors /> <h3><bean:message key=”logon.heading" /></h3> <html:form action="/LogonSubmit" focus="username"> <table width="100%"> <tr><th align="right">Username:</th> <td> <html:text property="username" /> </td></tr> <tr><th align="right">Password:</th> <td> <html:password property="password" /> </td></tr> 15 <html:password property password /> <tr><td align="right"> <html:submit /> </td> <td> <html:reset /> </td></tr> </table> </html:form> </body> Associating the ActionForm Bean with the HTML Form <action path="/LogonSubmit” type="app LogonAction" type= app.LogonAction name="logonForm" scope="request" validate="true" input="/pages/Logon.jsp"> <forward name="success" 16 path="/pages/Welcome.jsp"/> </action>
Background image of page 8
9 Form Beans Also Provide Values /pages/Logon.jsp <h3><bean:message key=”logon.heading" /></h3> <html:form action="/LogonSubmit" focus="username"> <table width="100%"> <tr><th align="right">Username:</th> <td> <html:text property="username" /> </td></tr>
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 21

06 - MVC with Struts (Logon Example) - CSE 135 MVC with...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online