Illegal Argument Exception

I am trying to figure this out. From my html form I call a servlet. In the servlet I am doing req.getParameter("name"), which I am passing thru the form. I am also checking to see if req.getParameter("name") is null or the length is 0. But it is giving me IllegalArgumentException at HttpUtils.parseQueryString. Can somebody explain to me as to what are the possible cause for getting this exception.

How is your servlet called ( get or post ?). Paste the code where you are in doubt of getting error. Thanks.

Vedprakash Pathak

Greenhorn

Posts: 24

posted 16 years ago

its using doPost

khudiram Barik

Greenhorn

Posts: 17

posted 16 years ago

Please paste the code , Note:--- req.getParameter("name") does not through any exception. It's somewhere else you are trying to do something else. Thanks.

Vedprakash Pathak

Greenhorn

Posts: 24

posted 16 years ago

and also I went inside the HttpUtils class and changed the parseQueryString to display more information, but it is not working. Is it that I can not change the standard classes in Java? The above mentioned method throws IllegalArgumentException(), what I wanted was to throw IllegalArgumentException(s), so that I can see what is the value of String s.

Any hints

Vedprakash Pathak

Greenhorn

Posts: 24

posted 16 years ago

This is the line no 49 in my code AddReseller.java

String rsCoCode = req.getParameter("name"); And this is the exception being thrown

java.lang.IllegalArgumentException at javax.servlet.http.HttpUtils.parseQueryString(HttpUtils.java) at javax.servlet.http.HttpUtils.parsePostData(HttpUtils.java) at org.apache.tomcat.util.RequestUtil.readFormData(RequestUtil.java) at org.apache.tomcat.core.RequestImpl.handleParameters(RequestImpl.java) at org.apache.tomcat.core.RequestImpl.getParameterValues(RequestImpl.java) at org.apache.tomcat.core.RequestImpl.getParameter(RequestImpl.java) at org.apache.tomcat.facade.HttpServletRequestFacade.getParameter(HttpServletRequestFacade.java) at epoch.servlets.AddReseller.doPost(AddReseller.java:49) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at javax.servlet.http.HttpServlet.service(HttpServlet.java) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java) at org.apache.tomcat.core.Handler.service(Handler.java) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java) at org.apache.tomcat.core.ContextManager.service(ContextManager.java) at org.apache.tomcat.service.connector.Ajp13ConnectionHandler.processConnection(Ajp13ConnectionHandler.java) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java) at java.lang.Thread.run(Thread.java:484)

khudiram Barik

Greenhorn

Posts: 17

posted 16 years ago

To my knowledge the single line you have shown does not look to have any problem. It is very difficult to know or assume the rest of your code unless we see that. Always entire code helps very much for other to understand. If you are concerned about that, it's OK. Hope you understand.

Vedprakash Pathak

Greenhorn

Posts: 24

posted 16 years ago

hi Khudiram,

The entire code is too lengthy and it contains company specific info, but here it is

That's enough, now I can suggest the following:--- Put a System.out.println surrounding the line 49 ( where you have doubt) System.out.println("Before this Line"); Line 49's code System.out.println("After this Line"); and rerun and see if you have pointed out the error line correctly. If so let me know I will do some more research to help you. Because those lines are simple req.getParameter("") lines and can not have error. By doing so you can track down the error line correctly. Thanks.

Vedprakash Pathak

Greenhorn

Posts: 24

posted 16 years ago

I did a try catch block for that line and it gave me IllegalArgument Exception.

khudiram Barik

Greenhorn

Posts: 17

posted 16 years ago

You have mentioned earlier that you changed HttpUtils's parseQueryString method, what change you made ? Can you change it back ? Second does name parameter contains a '&' character in the form ? I mean what value you enter in the screen ?