• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP, Struts, Bean Help

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the Struts forum.
bear
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
reply
    Bookmark Topic Watch Topic
  • New Topic