aspose file tools*
The moose likes Struts and the fly likes JSP, Struts, Bean Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSP, Struts, Bean Help" Watch "JSP, Struts, Bean Help" New topic
Author

JSP, Struts, Bean Help

Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
Well,
I have a struts development using the tomcat server. I have a JSP, logon.jsp and I could not exactly understand in general what these lines are doing...
<html:form action="/logon" focus="username"
onsubmit="return validateLogonForm(this);">
<table border="0" width="100%">
<tr>
<th align="right">
<bean:message key="prompt.username"/>:
</th>
<td align="left">
<html:text property="username" size="16" maxlength="18"/>
</td>
</tr>
especially something like this <bean:message key="prompt.username"/>:
Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

Moving to the Struts forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
veronique alvaro
Greenhorn

Joined: Sep 05, 2003
Posts: 24
Hi
<bean:message key="prompt.username"/>
It means that the jsp page is looking in the ApplicationResources.properties file (you can find it under the WEB-INF/src directory) the message corresponding to the key : prompt.username. You could have something like this in the ApplicationResources.properties file :
prompt.username = Enter Username :
So you can change the message, without changing the code in the jsp page as you just call the key in it.
When you run the application you have on the jsp page :
<table border="0" width="100%">
<tr>
<th align="right">
Enter Username :
</th>
<td align="left">
</td>
</tr>
Chanpreet Julka
Ranch Hand

Joined: Nov 09, 2001
Posts: 40
Great that makes a lot of sense. But, what is going on here.
<html:form action="/logon" focus="username"
onsubmit="return validateLogonForm(this);">
<table border="0" width="100%">
veronique alvaro
Greenhorn

Joined: Sep 05, 2003
Posts: 24
when you enter a username and submit it from the form, you call the action /logon from the struts-config.xml that could look like this:

This action is mapped with a bean named "logonForm" that you should find also in struts-config.xml described like this

The LogonAction (which extends Action) validates the username.
If the username is ok, you return (mapping.findForward("success"));
If the username is not ok, you return (mapping.findForward("failure"));
Going back to the Strut-config.xml, you can put for exemple in the global-forwards, the mapping for "success"
<forward name="success" path="/mainMenu.jsp"/>
If the user has the right username, it goes to mainMenu.jsp
Same for "failure" : you can redirect him for example back to the logon.jsp
<forward name="failure" path="/logon.jsp"/>
Hope it's clear !!!
V�ronique
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
The best approach to learning struts is not to jump into the examples, but by reading about it. A lot of nice documentation is avl at : http://www.apache.org


Adios
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP, Struts, Bean Help