Do you have any link where sample applications are available ? Thank
From: "Pani, Gourav" <[EMAIL PROTECTED]> To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]> Sent: Tuesday, February 04, 2003 12:39 PM Subject: RE: javax.servlet.ServletException > Eric, > > It doesn't appear as if you are utilizing some of the simple Struts > capabilities that would make things a lot easier. > > As far as the mapping goes, you should try the following in the > struts-config.xml. > > <struts-config> > <action-mappings> > <action path="/login" name="Login" type="com.javapro.struts.LoginAction" > scope="request" validate="true" input="login.jsp"> > <forward name="success" path="/jsp/main/welcome.jsp" /> > </action> > </action-mappings> > </struts-config> > > > the input would be the path to the JSP that is being used to enter > information and posting to your Action class. you should also have a form > object to hold the username and password instead of getting it from your > request. > > in the action class you can do the following: > > return mapping.findForward("success"); > > instead of using the request dispatcher. > > > you might want to consult sample applications available online. > > -----Original Message----- > From: EG [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, February 04, 2003 12:06 PM > To: Struts Users Mailing List > Subject: Re: javax.servlet.ServletException > > > Here the web.xml ane struts-config.xml > > <web-app> > > <!-- Action Servlet Configuration --> > <servlet> > <servlet-name>action</servlet-name> > <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> > </servlet> > > <!-- Action Servlet Mapping --> > <servlet-mapping> > <servlet-name>action</servlet-name> > <url-pattern>*.do</url-pattern> > </servlet-mapping> > > <!-- The Welcome File List --> > <welcome-file-list> > <welcome-file>login.jsp</welcome-file> > </welcome-file-list> > > </web-app> > > here the loginAction class > > package com.javapro.struts; > > import java.io.IOException; > import javax.servlet.RequestDispatcher; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpSession; > import javax.servlet.http.HttpServletResponse; > import org.apache.struts.action.Action; > import org.apache.struts.action.ActionForward; > import org.apache.struts.action.ActionForm; > import org.apache.struts.action.ActionMapping; > > public final class LoginAction extends Action { > public ActionForward execute(ActionMapping mapping, > ActionForm form, HttpServletRequest request, HttpServletResponse > response) > throws IOException, ServletException { > > String userName = request.getParameter("userName"); > String password = request.getParameter("password"); > if (userName!=null && password!=null && > userName.equals("eric") && password.equals("eric")) { > HttpSession session = request.getSession(); > session.setAttribute("loggedIn", "1"); > RequestDispatcher rd = request.getRequestDispatcher("/mainMenu.jsp"); > rd.forward(request, response); > } > else { > RequestDispatcher rd = request.getRequestDispatcher("/login.jsp"); > rd.forward(request, response); > } > return null; > } > } > > <struts-config> > <action-mappings> > <action path="/login" type="com.javapro.struts.LoginAction"/> > <action path="/logout" type="com.javapro.struts.LogoutAction"/> > <action path="/viewSecret" type="com.javapro.struts.ViewSecretAction"/> > </action-mappings> > </struts-config> > > > Thanks > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]