Hello everyone,
I am writing this simple struts application . I am getting errors and its hard to debug since I dont know what exactly is going wrong. Please help me out in this..Thank you very much in advance.
Wow, that's an old version of Struts--any reason you're learning it?
In any case--the thing I'd try first would be to rename the form bean by removing the "_XML" part--I don't know if it'll fix the issue, but it's easy to try.
Kalith Aazad wrote:The reason why I am learning Struts1 is that there are lot many applications in that. it adheres to basic rules like form-bean. Its widely used .
I was actually referring to the 1.0 part; that's like a decade old. If you're happy doing maintenance work, Struts 1 is fine--enjoy!
(Although I wouldn't call "form-bean" a "basic rule"--other frameworks behave quite differently.)
Check out the Javadocs for ActionMessage--I don't recall for 1.0, but nothing 1.1+ takes an immediate string; they're expecting a resource/message key.
How to check the version of Struts?
I have imported the following jar files and tld's in my eclipse folder
here is a snapshot of it.
Image of JAR and taglib files
(Note I'm giving you a hint about how to solve the problem: if you do not read the Javadocs, you may not discover how to do what it is you wish to do.)
Thank you. I am creating a applicationResource.properties file in the src/resources directory and mapping it onto struts-config.xml and will then create entities in the applicationResource.properties file to check if the appropriate keys are being called. Will keep you posted on this. I appreciate the help,.
Here is the thing i did,
I created the entity:
<message-resources parameter="resources.MessageResources" />
in the resources folder.
After that i added:
error.productName = Product name not found
error.price = price not entered
error.description = description not entered
to the MessageResources.properties
After that I modified the validate method in the ActionForm
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors actionErrors = new ActionErrors();
if (this.getProductName() == null)
actionErrors.add("ProductName", new ActionMessage(
"error.productName"));
if (this.getPrice() == null)
actionErrors.add("ProductPrice", new ActionMessage(
"error.price"));
if (this.getDescription() == null)
actionErrors.add("ProductDescription", new ActionMessage(
"error.description"));
return actionErrors;
}
Now I still get the same error
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 chapter2.multiPageForms.ProductForm.ProductFormBean: {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:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Exception creating bean of class chapter2.multiPageForms.ProductForm.ProductFormBean: {1}
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.jsps.ActionForms.DisplayAddProductForm_jsp._jspService(DisplayAddProductForm_jsp.java:102)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
javax.servlet.jsp.JspException: Exception creating bean of class chapter2.multiPageForms.ProductForm.ProductFormBean: {1}
org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:487)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:457)
org.apache.jsp.jsps.ActionForms.DisplayAddProductForm_jsp._jspx_meth_html_005fform_005f0(DisplayAddProductForm_jsp.java:138)
org.apache.jsp.jsps.ActionForms.DisplayAddProductForm_jsp._jspService(DisplayAddProductForm_jsp.java:91)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
At what point does the error occur? Are you trying to access the JSP page directly? Did you understand when I told you that reading the documentation would show you how to avoid creating a resource file (although this does not appear to be the immediate problem)?
Side notes: why do you configure your taglibs in the web.xml? That hasn't been necessary for years. How do you expect this code to work (besides that it appears to be completely unnecessary)--if it's null, what do you think this code would do?
This seems crazy, but I guess I used netbeans, as i used to use earlier, just tweaked the web.xml ...and cleaned and built the project.
Added the standard.jar and jstl.jar files
And the small app worked.
Thank you so very much for helping me out in this situation.I really appreciate it.
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is unnecessarily difficult to read. You can edit your post by using the button.