what to change please be specific coolsayan wrote: > > how to solve??why this <html:errors /> not working?? > > > > code in login.jsp > > <%...@page contentType="text/html"%> > <%...@page pageEncoding="UTF-8"%> > > <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" > %> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" > %> > <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" > prefix="logic" %> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > "http://www.w3.org/TR/html4/loose.dtd"> > <html> > <head> > <link rel="stylesheet" type="text/css" href="stylesheet.css"> > <meta http-equiv="Content-Type" content="text/html; > charset=UTF-8"> > <title>JSP Page</title> > </head> > <body> > <h1>Login Form</h1> > <html:errors /> > <html:form action="/login"> > <table border="0"> > > <tbody> > <tr> > <td> register.jsp Register to login </td> > </tr> > <tr> > <td>Enter Your user name:</td> > <td><html:text property="name" /></td> > </tr> > <tr> > <td>Enter Your Password:</td> > <td><html:password property="password" /></td> > </tr> > <tr> > > <td><html:submit value="Login" /></td> > <td><html:reset value="" /></td> > <td> forgetpass.jsp Forget Password </td> > </tr> > </tbody> > </table> > > > > > </html:form> > > </body> > </html> > > code in ActionBean: > > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > > package com.myapp.struts; > > import javax.naming.NamingException; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.*; > import javax.servlet.*; > //import javax.sql.DataSource; > import org.apache.struts.action.ActionErrors; > import org.apache.struts.action.ActionMapping; > import org.apache.struts.action.ActionMessage; > //import sun.jdbc.odbc.JdbcOdbcDriver; > > /** > * > * @author Administrator > */ > public class LoginForm extends org.apache.struts.action.ActionForm { > //private JdbcOdbcDriver serviceLocator; > > private String name; > //private String name; > private String password; > > public String getPassword() { > return password; > } > > public void setPassword(String password) { > this.password = password; > } > > private int number; > > /** > * @return > */ > public String getName() { > return name; > } > > /** > * @param string > */ > public void setName(String string) { > name = string; > } > > /** > * @return > */ > public int getNumber() { > return number; > } > > /** > * @param i > */ > public void setNumber(int i) { > number = i; > } > > /** > * > */ > public LoginForm() { > super(); > // TODO Auto-generated constructor stub > } > > /** > * This is the action called from the Struts framework. > * @param mapping The ActionMapping used to select this instance. > * @param request The HTTP Request we are processing. > * @return > */ > > public ActionErrors validate(ActionMapping mapping, HttpServletRequest > request) { > ActionErrors errors = new ActionErrors(); > if (getName() == null || getName().length() < 1) { > errors.add("name", new ActionMessage("error.name.required")); > // TODO: add 'error.name.required' key to your resources > } > return errors; > } > > > > > } > > code in Action servlet: > > /* > * To change this template, choose Tools | Templates > * and open the template in the editor. > */ > package com.myapp.struts; > > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > import javax.servlet.http.*; > import java.io.*; > import org.apache.struts.action.Action; > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionMapping; > import org.apache.struts.action.ActionForward; > > /** > * > * @author Administrator > */ > public class LoginAction extends org.apache.struts.action.Action { > > /* forward name="success" path="" */ > private final static String SUCCESS = "success"; > private final static String FAILURE = "failure"; > > /** > * This is the action called from the Struts framework. > * @param mapping The ActionMapping used to select this instance. > * @param form The optional ActionForm bean for this request. > * @param request The HTTP Request we are processing. > * @param response The HTTP Response we are processing. > * @throws java.lang.Exception > * @return > */ > public ActionForward execute(ActionMapping mapping, ActionForm form, > HttpServletRequest request, HttpServletResponse response) > throws Exception { > LoginForm formBean = (LoginForm) form; > String name = formBean.getName(); > String password = formBean.getPassword(); > > // perform validation > if ((name.isEmpty()) || // name parameter does not exist > password == null || // email parameter does not exist > name.equals("") || // name parameter is empty > password.isEmpty()) { // password lacks '@' > > return mapping.findForward(FAILURE); > } > > HttpSession mySession=request.getSession(true); > mySession.setMaxInactiveInterval(30); > return mapping.findForward(SUCCESS); > } > } > > > > > Error > > HTTP Status 500 - > > -------------------------------------------------------------------------------- > > type Exception report > > message > > descriptionThe server encountered an internal error () that prevented it > from fulfilling this request. > > exception > > javax.servlet.ServletException: PWC1244: Servlet execution threw an > exception > root cause > > java.lang.NoSuchMethodError: > org.apache.struts.config.ForwardConfig.getContextRelative()Z > note The full stack traces of the exception and its root causes are > available in the Sun GlassFish Enterprise Server v2.1 logs. > > > -------------------------------------------------------------------------------- > > Sun GlassFish Enterprise Server v2.1 >
-- View this message in context: http://www.nabble.com/%3Chtml%3Aerrors-%3E-error-validation-error-tp23765113p23784799.html Sent from the Struts - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org