This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes logic and bean tag in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "logic and bean tag in struts" Watch "logic and bean tag in struts" New topic
Author

logic and bean tag in struts

Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 54
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.
Raaja Gotluru
Ranch Hand

Joined: Mar 02, 2010
Posts: 84
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.
candid java
Greenhorn

Joined: Jan 13, 2012
Posts: 14
here i was found the exact answer by this link http://candidjava.com/struts-1x-validation-with-example-program-in-eclipse
 
I agree. Here's the link: http://jrebel.com/download
 
subject: logic and bean tag in struts
 
Similar Threads
how to do validation in struts1
taglib in JSP not working in struts
Verification failed on Username existence check using AJAX
change password
How to display error message