Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Struts
Search Coderanch
Advance search
Google search
Register / Login
Help coderanch get a
new server
by contributing to the
fundraiser
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:
Campbell Ritchie
Ron McLeod
Paul Clapham
Devaka Cooray
Liutauras Vilda
Sheriffs:
Jeanne Boyarsky
paul wheaton
Henry Wong
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Tim Moores
Carey Brown
Mikalai Zaikin
Bartenders:
Lou Hamers
Piet Souris
Frits Walraven
Forum:
Struts
Kindly help me in fixing the bug . error 404
ashwini hikulkarni
Greenhorn
Posts: 25
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<%@ page language="java"%> <%@ page import="java.io.*"%> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> <html:html> <center><IMG SRC="E:\jboss-4.0.3SP1\server\default\deploy\TestApplication.war\image\welcome.jpg" HEIGHT=233 WIDTH=282 ALT="WELCOME TO DATAMATICS"></center> <center><h1 style="color:blue"><hr>WELCOME TO DATAMATICS</hr></h1></center> <h2 style="color:green">LOGIN FORM</h2> <html:errors/> <center> <body> <html:form action="/login" method="POST" > <table width="20%" border="0"> <td> <tr><h4 style="color:red">USER ID:<h4></tr> <tr><html:text property="username" size="30"/></tr> <hr> </td> <td> <tr><h4 style="color:red">PASSWORD:</h4></tr> <tr><html assword property="password" size="30" /></tr> <hr> <tr><html:submit>SUBMIT </html:submit></tr><hr> <tr><html:reset/></tr> <tr></tr> </td> </table> </body> </html:form> </center> </html:html> 2>LoginAction.java package com.MyPack.Datamatics; import com.MyPack.Datamatics.LoginForm; import javax.servlet.http.*; import java.io.*; import javax.servlet.ServletException; import org.apache.struts.action.Action; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionError; public class LoginAction extends Action { public ActionForward execute(ActionMapping am, ActionForm form, HttpServletRequest req, HttpServletResponse res)throws IOException, ServletException { System.out.println("andy1"); String target= new String("success"); if(form!=null) { LoginForm loginForm = (LoginForm)form; System.out.println("andy2"); String userName = loginForm.getUsername(); System.out.println("andy3"); String password = loginForm.getPassword(); System.out.println("andy4"); if (userName.equalsIgnoreCase("Datamatics") && password.equalsIgnoreCase("12345")) { req.setAttribute("UserName",userName); System.out.println("andy5"); } else { target = new String("failure"); System.out.println("andy6"); } } return am.findForward(target); } } 3>LoginForm.java package com.MyPack.Datamatics; import com.MyPack.Datamatics.LoginAction; import javax.servlet.http.*; import org.apache.struts.action.Action.*; import org.apache.struts.action.ActionForm; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionError.*; //import java.util.*; //import java.io.*; public class LoginForm extends ActionForm { private String username=null; private String password=null; public void setUsername(String username) { this.username=username; } public String getUsername() { return username; } public void setPassword(String password) { this.password=password; } public String getPassword() { return password; } public void reset(ActionMapping am,HttpServletRequest req) { this.username=""; this.password=""; } public ActionErrors validate(ActionMapping am, HttpServletRequest req) { ActionErrors ae = new ActionErrors(); if ( (username==null) || (username.length()==0)) { ae.add("username" , new ActionMessage("errors.username.required") ); } if( (password==null) || (password.length()==0)) { ae.add("password" , new ActionMessage("errors.password.required") ); } return ae; } } 4>struts-config.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <struts-config> <form-beans> <form-bean name="loginForm" type="com.MyPack.Datamatics.LoginForm" /> <form-bean name="uploadForm" type="com.MyPack.Datamatics.UploadForm" /> </form-beans> <global-forwards> <forward name="success" path="/index.jsp"/> </global-forwards> <action-mappings> <action path="/login" type="com.MyPack.Datamatics.LoginAction" name="loginForm" scope="request" input="/login.jsp"> <forward name="success" path="/upload.jsp" /> <forward name="fail" path="/index.jsp" /> </action> <action path="/upload" type="com.MyPack.Datamatics.UploadAction" name="uploadForm" scope="request" input="/upload.jsp"> <forward name="success" path="/successUpload.jsp" /> <forward name="fail" path="/index.jsp" /> </action> </action-mappings> </struts-config> 5>web.xml <web-app> <servlet> <servlet-name>ActionServlet</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config </param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>application </param-name> <param-value>ApplicationResources</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mappings> <servlet-name>ActionServlet</servlet-name> <url-mapping>*.do</url-mapping> </servlet-mappings> <taglib> <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> <taglib-location>/WEB-INF/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> </taglib> </web-app>
Exception Raised
HTTP Status 404 - /TestApplication/login.do -------------------------------------------------------------------------------- type Status report message /TestApplication/login.do description The requested resource (/TestApplication/login.do) is not available. -------------------------------------------------------------------------------- Apache Tomcat/5.5
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
problem in internationalization
Getting exception: Module 'null' not found
exception in uploading the file
I am unable to resolve the exception
org.apache.jasper.JasperException: Module 'null' not found.
More...