Solved

How to fix this strange struts problem

Posted on 2009-05-13
2
7,317 Views
Last Modified: 2013-11-24
Hi folks,

We are experiencing a very strange problem when submitting a form in Struts, and we would really like to fix the problem instead of using a patch.

Here is the problem :
1. The user fills the JSP form as usual;
2. The user clicks on the submit button in order to delete the data;
3. The user get the following error message :  
javax.servlet.ServletException: Request[/treatmentEditValidate] does not contain handler parameter named 'method'.  This may be caused by whitespace in the label text.

In TreatmentEditForm.java, we have a method named "validate" :
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

ActionErrors errors = new ActionErrors();

>> validations are coded here.

return errors;
}

We tested the method with the Eclipse SDK debug mode. Everything runs fine until the method tries to redirect the user at the end of the validate method. request.getSession().getAttribute("method") isn't null and has the right data : "saveDelete";

After a tons of research, we found a patch, which consists in overriding the "unspecified" struts method :
In TreatmentEditAction.java :
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws CreateException, NamingException {

                if(request.getSession().getAttribute("method").equals("deleteTreatment")) {
                      saveDelete(mapping, form, request, response);
                }
          
                return mapping.findForward("success");
    }

By doing this override, everything works just fine. It always occurs when we try to delete. We use the same ActionForm for add, update and delete. This is a bit disappointing since add and update works perfectly.

Anyone ever experienced this strang problem?

Thank you very much
0
Comment
Question by:SolutionsTI
2 Comments
 
LVL 6

Expert Comment

by:dnunes_br
Comment Utility
Change the name of the method and see if it works. It could be some incompatibility because this method is already used by Struts. Check at:

http://struts.apache.org/1.x/userGuide/building_view.html
0
 

Accepted Solution

by:
SolutionsTI earned 0 total points
Comment Utility
We finally found the problem, which is really strange!!

In delete screens, we disable all html elements such as textbox, select, radiobuttons and checkbox in order to avoid any data input from the user. The only options are Yes (delete the file) and No (cancel and go back to the previous screen).

The method is stored in a hidden field, so the form is submitted along with the method field. Guess what, javascript CAN disable hidden field, so the method field was not submitted correctly, causing the following error message :
javax.servlet.ServletException: Request[/treatmentEditValidate] does not contain handler parameter named 'method'.  This may be caused by whitespace in the label text.

Thank you very much for the link, dnunes_br
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now