Welcome to Dream.In.Code
Getting Help is Easy!

Join 117,165 Programmers for FREE! Ask your question and get quick answers from experts. There are 2,529 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



HTTP Status 500 - type Exception report description The server encoun

 
Reply to this topicStart new topic

HTTP Status 500 - type Exception report description The server encoun, m new to struts trying to deploy my first struts application but getti

CK12
post 25 Jun, 2008 - 04:51 AM
Post #1


New D.I.C Head

*
Joined: 17 Jun, 2008
Posts: 1

The flow of my application is like this-
It has index.jsp which is to be displayed first.It has link to CustomerDetails.jsp.
It shd show this page on clicking on this link.
But it is giving above specified error on clicking on this link.

Can anybody pls help me out to resolve this problem....m fedup of it......

my code is as follows-


CODE



WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>Hello World Struts Application</display-name>
    <servlet>
        <servlet-name>action</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>debug</param-name>
            <param-value>3</param-value>
        </init-param>
        <init-param>
            <param-name>detail</param-name>
            <param-value>3</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        </servlet>
    <servlet-mapping>
        <servlet-name>action</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>
    <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-bean.tld</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
    </taglib>
  
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        </welcome-file-list>
    </web-app>


[b][color=#FF0000]STRUTS-CONFIG.XML[/color][/b]

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">


<struts-config>
    <form-beans>
        <form-bean name="CustomerForm" type="CustomerForm"/>
    
    </form-beans>
    
    <global-exceptions>
    
    </global-exceptions>

    <global-forwards>
        <forward name="mainpage"  path="/index.jsp"/>
    </global-forwards>

    <action-mappings>
        <action path="/submitCustomerForm" type="CustomerAction" validate="true" input="CustomerDetails.jsp">
         <forward name="success" path="Success.jsp" />
         <forward name="failure" path="Failure.jsp" />
       <!--<action path="/Welcome" forward="/welcomeStruts.jsp"/>-->
       </action>
   </action-mappings>
    
    <controller processorClass="org.apache.struts.action.RequestProcessor"/>

    <message-resources parameter="App1Messages.properties.properties"/>    
    
     </struts-config>

[b]CUSTOMERDETAILS FORM BEAN[/b][color=#FF0000]


import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class CustomerForm extends org.apache.struts.action.ActionForm {
    
   private String firstName;

   private String lastName;

      public CustomerForm() {
firstName = "";
lastName = "";
}
  
   public String getFirstName() {
       return firstName;
   }

      public void setFirstName(String s) {
       this.firstName = s;
   }

      public String getLastName() {
       return lastName;
   }

      public void setNumber(String t) {
       this.lastName = t;
   }

  
   public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
       ActionErrors errors = new ActionErrors();
       if (firstName == null || firstName.trim().equals("")) {
           errors.add("firstName", new ActionMessage("error.name.required"));
           // TODO: add 'error.name.required' key to your resources
       }
       return errors;
   }
}


[b][color=#FF0000]ACTION CLASS [/color] [/b]




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.ActionMapping;
import org.apache.struts.action.ActionForward;

public class CustomerAction extends org.apache.struts.action.Action
{
    
         public ActionForward execute(ActionMapping mapping, ActionForm  form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception
    {
      if(isCancelled(request))
      {
          System.out.println("Cancel Operation Performed");
          return mapping.findForward("mainpage");
      }
      CustomerForm custForm=(CustomerForm) form;
      String firstName=custForm.getFirstName();
      String lastName=custForm.getLastName();
      System.out.println("Customer Firstname is" + firstName);
      System.out.println("Customer Lastname is" + lastName);  
      ActionForward forward=mapping.findForward("success");
      return forward;
    }
}


[b][color=#FF0000]INDEX.JSP[/color][/b]


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html:html>
<head>

<body>
   <html:link page=”CustomerDetails.jsp”>Customer Form</html:link>
</body>
</html:html>

[b][color=#FF0000]CUSTOMERDETAILS.JSP[/color][/b]


<%--
    Document   : CustomerDetails
    Created on : Jun 24, 2008, 4:50:29 PM
    Author     : CKulkarn
--%>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<html:html>
<head>
<html:base/>
</head>
<body>
<html:errors/>
<html:form action="/submitCustomerForm">
<bean:message key="prompt.customer.firstname"/>:
<html:text property="firstName" size="16" maxlength="16"/>
<BR>
<bean:message key="prompt.customer.lastname"/>:
<html:text property="lastName" size="16" maxlength="16"/>
<BR>
<html:submit>
<bean:message key="button.save"/>
</html:submit>
&nbsp;
<html:cancel>
<bean:message key="button.cancel"/>
</html:cancel>
</html:form>
</body>
</html:html>






This post has been edited by CK12: 25 Jun, 2008 - 05:01 AM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/6/08 11:22AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month