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.