Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > Servlets
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 29th, 2007, 05:20 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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
Reply With Quote
  #2 (permalink)  
Old January 29th, 2007, 05:23 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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>

Reply With Quote
  #3 (permalink)  
Old January 29th, 2007, 05:25 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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;
      }
}

Reply With Quote
  #4 (permalink)  
Old January 29th, 2007, 05:27 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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");
        }
     }

Reply With Quote
  #5 (permalink)  
Old January 29th, 2007, 06:13 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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"

Reply With Quote
  #6 (permalink)  
Old January 29th, 2007, 07:29 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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>

Reply With Quote
  #7 (permalink)  
Old January 29th, 2007, 09:07 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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>

Reply With Quote
  #8 (permalink)  
Old January 29th, 2007, 09:10 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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)..

Reply With Quote
  #9 (permalink)  
Old January 29th, 2007, 09:11 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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");
    }

Reply With Quote
  #10 (permalink)  
Old January 29th, 2007, 09:13 AM
Authorized User
 
Join Date: Sep 2006
Location: , , .
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)

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 04:58 PM
javax.servlet problem anupamda JSP Basics 2 June 23rd, 2004 10:59 PM



All times are GMT -4. The time now is 03:50 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.