Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Servlets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 29th, 2007, 05:20 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default javax.servlet.ServletException: Exception creating

hi guys..i was trying out the Dispatch action and was not able to succeed..so i changed the coding to normal forward action..

but i get the following error...(immediately after the error below i have given the codes of different files being used)


javax.servlet.ServletException: Exception creating bean of class ch03.Dispatch: {1}
    org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:825)
        .....
        ..... in browser

Jan 29, 2007 2:23:55 PM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en_US.properties Not Found.
Jan 29, 2007 2:23:55 PM org.apache.struts.util.PropertyMessageResources loadLocale
WARNING: Resource org/apache/struts/action/ActionResources_en.properties Not Found.
Jan 29, 2007 2:23:55 PM org.apache.struts.util.RequestUtils createActionForm
SEVERE: Error creating form bean of class ch03.Dispatch
java.lang.IllegalAccessException: Class org.apache.struts.config.FormBeanConfig can not access a member of class ch03.Dispatch with modifiers ""
    at sun.reflect.Reflection.ensureMemberAccess(Reflecti on.java:57)
    at java.lang.Class.newInstance0(Class.java:302)
    at java.lang.Class.newInstance(Class.java:261)
        .....
        .....in the console
 
Old January 29th, 2007, 05:23 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

struts-config.xml file

<form-beans>
            <form-bean name="dispatch" type="ch03.Dispatch" />
</form-beans>

<action-mappings>
    <action path = "/dispatchUserSubmit" type = "ch03.UserDispatchAction" name = "dispatch" >
         <forward name="jump" path="/admin/jumped.jsp" />
         <forward name="stay" path="/admin/dispatch.jsp" />
    </action>
</action-mappings>

<global-forwards>
    <forward name = "Dispatch" path = "/Dispatch.do" />
</global-forwards>

 
Old January 29th, 2007, 05:25 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

index.jsp

<html:link forward = "Dispatch" >DISPATCHing Actions</html:link>

Dispatch.java

package ch03;

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

class Dispatch extends ActionForm
{
    private String method = null;

      public String getmethod() {

        return (method);
      }

      public void setmethod(String method) {

        this.method = method;

      }

      public void reset(ActionMapping mapping, HttpServletRequest request) {

        this.method = null;
      }
}

 
Old January 29th, 2007, 05:27 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

UserDispatchAction.java

package ch03;

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

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

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

                  System.out.println("JUMP USER");
                  return mapping.findForward("jump");
        }
     }

 
Old January 29th, 2007, 06:13 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

why do i get this error if the dispatch java file is associated with name = "dispatch"

 
Old January 29th, 2007, 07:29 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the dispatch.jsp file

<%@ page language="Java" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<html>
<head>
<title>
dispatch form bean
</title>
</head>
<body>
JUMP/STAY
     <html:form action="/dispatchUserSubmit">
      <table width="40%" border="20">
        <tr>
          <td>Method Name is :</td>
          <td><html:text property="method" /></td>
        </tr>
        <tr>
          <td colspan="2" align="center">
          <html:submit /></td>
        </tr>
       </table>

      </html:form>
</body>
</html>

 
Old January 29th, 2007, 09:07 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i solved the problem..

the culprit turned out to be the dispatch.jsp

instead of the <html:text property="method"/>

to be used
<html:select property="method" size="12">
                     <html:option value="jump">jump</html:option>
                     <html:option value="stay">stay</html:option>
                  </html:select>

 
Old January 29th, 2007, 09:10 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok the above solution was for dispatch action itself..not the previously discussed problem(forward)..

 
Old January 29th, 2007, 09:11 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the coressponding change that should b done in UserDispatchAction.java is

remove the execute method and add following code..

 public ActionForward jump(ActionMapping mapping,ActionForm form,HttpServletRequest request,
         HttpServletResponse response) throws Exception {

              System.out.println("JUMP USER");
              return mapping.findForward("jump");
    }

    public ActionForward stay(ActionMapping mapping,ActionForm form,HttpServletRequest request,
         HttpServletResponse response) throws Exception {

              System.out.println("STAY USER");
              return mapping.findForward("stay");
    }

 
Old January 29th, 2007, 09:13 AM
Authorized User
 
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i dont see any reason for the problem i described above(topic)..

i guess the culprit to be the Dispatch.java(i guess)






Similar Threads
Thread Thread Starter Forum Replies Last Post
Exception in thread "main" javax.xml.transform.Tra XSLTUser XSLT 1 December 29th, 2007 04:59 AM
Package javax.servlet.jsp does not exist wottt JSP Basics 5 January 17th, 2007 06:37 AM
javax.servlet gauravchhabra9111 Servlets 1 January 19th, 2005 03:14 AM
package javax.servlet does not exist ...HELP Jil Servlets 3 September 12th, 2004 03:58 PM
javax.servlet problem anupamda JSP Basics 2 June 23rd, 2004 09:59 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.