 |
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
|
|
|
|

January 29th, 2007, 05:20 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

January 29th, 2007, 05:23 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
|

January 29th, 2007, 05:25 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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;
}
}
|
|

January 29th, 2007, 05:27 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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");
}
}
|
|

January 29th, 2007, 06:13 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
why do i get this error if the dispatch java file is associated with name = "dispatch"
|
|

January 29th, 2007, 07:29 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
|

January 29th, 2007, 09:07 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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>
|
|

January 29th, 2007, 09:10 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
ok the above solution was for dispatch action itself..not the previously discussed problem(forward)..
|
|

January 29th, 2007, 09:11 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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");
}
|
|

January 29th, 2007, 09:13 AM
|
|
Authorized User
|
|
Join Date: Sep 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i dont see any reason for the problem i described above(topic)..
i guess the culprit to be the Dispatch.java(i guess)
|
|
 |