This week's book giveaway is in the Java in General forum.
We're giving away four copies of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 and have ishori Sharan & Adam L Davis on-line!
See this thread for details.
Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

logic and bean tag in struts

 
Ranch Hand
Posts: 161
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
register.jsp

<%@taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<html:form action="register">
UserName:<html:text property="username"/> <br>
Password: <html:password property="password"/> <br>
<html:submit value="register"/>
</html:form>
<logic:notEmpty name="resultmsg">
Result is: <bean:write name="resultmsg"/>
</logic:notEmpty>


RegisterAction.java

package surya;
import org.apache.struts.action.*;
import javax.servlet.http.*;
public class RegisterAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res) throws Exception
{
System.out.println("Action class execute() is called");
RegisterForm fm=(RegisterForm)form;
String uname=fm.getUsername();
String pwd=fm.getPassword();
if(uname.equals("Sathya")&&pwd.equals("tech"))
{req.setAttribute("resultmsg","validcredentials");

}
else
{
req.setAttribute("resultmsg","Invalidcredentials");

}
return mapping.findForward("myres");
}
}


Whats the use of bean and logic tags here ? I am not getting the correct idea.
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swapna,

The code between logic tag executes only when the tag evaluates to true.



In the above code the value of the bean resultmsg will be diplayed only when the bean resultmsg is not null or when the bean is having some value.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here i was found the exact answer by this link http://candidjava.com/struts-1x-validation-with-example-program-in-eclipse
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic