Hi all,,
I am having a big troulbe with Servlet Basics....
The problem is that when i run this program i am getting the following
error
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented
it from fulfilling this request.
exception
org.apache.jasper.JasperException: javax.servlet.ServletException:
javax.servlet.jsp.JspException: Exception creating bean of class
hello.HelloForm: {1}
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:
522)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:
390)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException:
Exception creating bean of class hello.HelloForm: {1}
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:
850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:
779)
org.apache.jsp.hello_jsp._jspService(hello_jsp.java:116)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:
390)
root cause
javax.servlet.jsp.JspException: Exception creating bean of class
hello.HelloForm: {1}
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:487)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)
org.apache.jsp.hello_jsp._jspx_meth_html_005fform_005f0(hello_jsp.java:
150)
org.apache.jsp.hello_jsp._jspService(hello_jsp.java:97)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:
374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:
337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:
390)
***********************************************************
This is my index.jsp:
*************************************************************
<!-- Replace the contents of this file from the one in Code-15 -->
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head><title>Hello example</title></head>
<body>
<html:errors/>
<html:form action="hello.do">
User Name: <html:text property="userName"/><br>
<html:submit/>
</html:form>
<logic:present name="userName" scope="request">
Hello
<bean:write name="userName" scope="request"/>
</logic:present>
</body>
</html>
****************************************************
This is my indexnopassionname.jsp:
****************************************************
<!-- Replace the contents of this file from the one in Code-15 -->
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head><title>Hello example</title></head>
<body>
<h3>Example Hello Failure Page</h3>
<html:errors/>
<html:form action="hello.do">
User Name: <html:text property="userName"/><br>
<html:submit/>
</html:form>
<logic:present name="userName" scope="request">
Hello
<bean:write name="userName" scope="request"/>
</logic:present>
</body>
</html>
*****************************************************************************
This is my indexpassioname.jsp
*****************************************************************************
<!-- Replace the contents of this file from the one in Code-15 -->
<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head><title>Hello example</title></head>
<body>
<h3>Example Hello Success Page</h3>
<html:errors/>
<html:form action="hello.do">
User Name: <html:text property="userName"/><br>
<html:submit/>
</html:form>
<logic:present name="userName" scope="request">
Hello
<bean:write name="userName" scope="request"/>
</logic:present>
</body>
</html>
********************************************************
This is my HelloAction.java
********************************************************
package passion;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public final class HelloAction extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) {
HelloForm f = (HelloForm) form;
String username = f.getUserName();
if (username.startsWith("passion")||
username.startsWith("Passion") ){
request.setAttribute("username", username.toUpperCase());
return (mapping.findForward("success"));
} else{
return (mapping.findForward("failure"));
}
}
}
************************************************************************
This is my HelloForm.java
***********************************************************************
package passion;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.*;
public final class HelloForm extends ActionForm {
/* Getter and Setter methods of properties */
/* Getter and Setter methods of Last Name property */
private String userName = "Your User name"; // default value
public String getUserName() {
return (this.userName);
}
public void setUserName(String uName) {
this.userName = uName;
}
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
servlet.log("Username:" + userName);
ActionErrors errors = new ActionErrors();
if (userName == null || userName.equals("")) {
errors.add("Name", new ActionError("error.UserName"));
}
if (userName.length()<=3) {
errors.add("Name", new
ActionError("error.userNameLength"));
}
return errors;
}
}
*******************************************************************
This is my struts.config.xml
******************************************************************
<?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="HelloForm" type="hello.HelloForm"/>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
<forward name="hello" path="/hello.do"/>
</global-forwards>
<action-mappings>
<action path="/hello"
type="hello.HelloAction"
name="HelloForm"
input="/indexnopassionname.jsp"
scope="request"
validate="true">
<forward name="success" path="/indexpassionname.jsp"/>
<forward name="failure" path="/indexnopassionname.jsp"/>
</action>
</action-mappings>
<controller
processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
<message-resources parameter="com/myapp/struts/
ApplicationResource"/>
<!-- ========================= Tiles plugin
===============================-->
<!--
This plugin initialize Tiles definition factory. This later can
takes some
parameters explained here after. The plugin first read parameters
from
web.xml, thenoverload them with parameters defined here. All
parameters
are optional.
The plugin should be declared in each struts-config file.
- definitions-config: (optional)
Specify configuration file names. There can be several comma
separated file names (default: ?? )
- moduleAware: (optional - struts1.1)
Specify if the Tiles definition factory is module aware. If true
(default), there will be one factory for each Struts module.
If false, there will be one common factory for all module. In this
later case, it is still needed to declare one plugin per module.
The factory will be initialized with parameters found in the first
initialized plugin (generally the one associated with the default
module).
true : One factory per module. (default)
false : one single shared factory for all modules
- definitions-parser-validate: (optional)
Specify if xml parser should validate the Tiles configuration
file.
true : validate. DTD should be specified in file header (default)
false : no validation
Paths found in Tiles definitions are relative to the main context.
-->
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/
tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
</plug-in>
<!-- ========================= Validator plugin
================================= -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/
validation.xml"/>
</plug-in>
</struts-config>
************************************************************************
This is my ApplicationResource
***********************************************************************
errors.header=<h4>Validation Error(s)</h4><ul>
errors.footer=</ul><hr>
error.userName=<li>Enter your User name
error.userNameLength=<li>Your user name must be more than 3
characters
I have lookedinto other discussion in this forum but i dont seem to be
able to get the problem with this..
Cpuld someone plz help me
I would really appreciate the help
Thanks and Regards
Vithya
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---