Solved

How to fix this strange struts problem

Posted on 2009-05-13
2
7,356 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 65
Impossible to extract MSI from new JAVA releases 2 47
Non-recursive backtracking, using a stack 1 94
expectj telnet failing 5 17
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

943 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

9 Experts available now in Live!

Get 1:1 Help Now