Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to fix this strange struts problem

Posted on 2009-05-13
2
Medium Priority
?
7,713 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

885 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