Solved

How to fix this strange struts problem

Posted on 2009-05-13
2
7,452 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
ID: 24379039
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
ID: 24384530
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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 236
Glassfish admin console not working 1 53
Html Table Looping (part 2) 5 34
Select statement in @Query (JPA Repository) - SpringMVC 2 33
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

679 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