Solved

How to fix this strange struts problem

Posted on 2009-05-13
2
7,484 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

738 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