• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

HTTP Status 404 - Servlet action is not available

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to struts.. I am developing a student details login page.. After entering the details, it should redirect to success page or failure page if all the details are not provided.. But am getting " servlet action not found" error after submitting the form.. Am unable to find the mistake.. Please suggest me about that error.

Thanks in advance..

StudentForm.java
--------------------
package info.student;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class StudentForm extends ActionForm
{
private String name;
private String address;
private String emailAddress;

public void setName(String name){
this.name=name;
}

public String getName(){
return this.name;
}

public void setAddress(String address){
this.address=address;
}

public String getAddress(){
return this.address;
}


public void setEmailAddress(String emailAddress){
this.emailAddress=emailAddress;
}

public String getEmailAddress(){
return this.emailAddress;
}


public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request)
{
ActionErrors actionErrors = new ActionErrors();
try
{
if (name == null || name.length() == 0) {
actionErrors.add("name", new ActionMessage(
"name.required"));
}
} catch (Exception e) {
e.printStackTrace();
}

try {
if (address == null || address.length() == 0) {
actionErrors.add("address", new ActionMessage(
"address.required"));
}
}catch (Exception e) {
e.printStackTrace();
}

try{
if (emailAddress == null || emailAddress.length() == 0) {
actionErrors.add("emailAddress", new ActionMessage(
"emailAddress.required"));
}
}catch (Exception e) {
e.printStackTrace();
}
return actionErrors;
}

}


StudentAction.java
-----------------
package info.student;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class StudentAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{

System.out.println("execute method");

StudentForm sf=(StudentForm)form;

String sname=sf.getName();
String sadd=sf.getAddress();
String semail=sf.getEmailAddress();

System.out.println("values returned");

if(sname==null || sadd==null || semail==null){

System.out.println("redirecting to failure page");
return mapping.findForward("failure");
}
else{
System.out.println("redirecting to success page");
return mapping.findForward("success");
}
}
}

struts-config.xml
-----------------
<form-beans>
<form-bean name="sdetails" type="info.student.StudentForm">
</form-bean>
</form-beans>

<action-mappings>
<action path="/student" type="info.student.StudentAction" name="sdetails" scope="request" validate="true">
<forward name="success" path="/loginsuccess.jsp"></forward>
<forward name="failure" path="/loginfailure.jsp"></forward>
</action>
</action-mappings>

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi, send your login page code.
 
Vidya Gupta
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

<html:form action="/student" method="post">

Name: <html:text property="name" />

Address:<html:textarea property="address" />

Email Id: <html:text property="emailAddress" />

<html:submit /> <html:reset/>

</html:form>
 
Ranch Hand
Posts: 329
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Lalitha,
Are there any errors in the application log? if any, post the error log. Have you tried debugging to see if it reaches the validate method?
 
I have always wanted to have a neighbor just like you - Fred Rogers. Tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic