Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

URLDecoder.decode question

Status
Not open for further replies.

vasah20

Programmer
Feb 16, 2001
559
US
How come, given these two URLS:
1)
2)
The second one works correctly, but the first one keeps giving me a null error.

The error comes when I try to do the URLDecode...

Here's the relevant code:
Code:
  public void doGet(HttpServletRequest rq, HttpServletResponse rs) 
    throws ServletException, IOException {
    out = rs.getWriter();
    rs.setContentType("text/html");
    HttpSession sess = rq.getSession();

    //see if we should page, or not
    String st = (rq.getParameter("st") == null)?"1":rq.getParameter("st");
    String len = (rq.getParameter("len") == null)?"20":rq.getParameter("len");
    String sortby = (rq.getParameter("sort") != null)?rq.getParameter("sort"):"PMT_Number";
    String id = rq.getParameter("id"), 
      cmd = rq.getParameter("cmd"),
      type = rq.getParameter("type");
    String wh = rq.getParameter("wh");

    if(wh != null)
      urlWh = java.net.URLDecoder.decode(wh);

    boolean print = (rq.getParameter("print") != null)?true:false;
    boolean auth = false;

    if(sess.getAttribute("login.superuser") != null) 
      auth = ((String)sess.getAttribute("login.superuser")).equalsIgnoreCase("true"); 

    if(auth && id != null) {
      showEditUI(id,cmd);
    } else {
      if(cmd != null) {
        if(cmd.equalsIgnoreCase("advsearch")) showAdvSearch();
      } else if (urlWh == null)
        dispPMTS(Integer.parseInt(st),Integer.parseInt(len),sortby, auth, print);
      else 
        dispPMTS(Integer.parseInt(st),Integer.parseInt(len),sortby, auth, print, urlWh);
    } //end i

And, here's the error:
Code:
500 Internal Server Error
/servlet/cctservlets.PMT:

null
java.lang.IllegalArgumentException
	at java.net.URLDecoder.decode(URLDecoder.java:55)
	at cctservlets.PMT.doGet(PMT.java:36)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
	at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
	at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
	at allaire.jrun.servlet.JRunNamedDispatcher.forward(../servlet/JRunNamedDispatcher.java:34)
	at allaire.jrun.servlet.Invoker.service(../servlet/Invoker.java:84)
	at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1013)
	at allaire.jrun.servlet.JRunSE.runServlet(../servlet/JRunSE.java:925)
	at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/JRunRequestDispatcher.java:88)
	at allaire.jrun.servlet.JRunSE.service(../servlet/JRunSE.java:1131)
	at allaire.jrun.servlet.JvmContext.dispatch(../servlet/JvmContext.java:330)
	at allaire.jrun.http.WebEndpoint.run(../http/WebEndpoint.java:107)
	at allaire.jrun.ThreadPool.run(../ThreadPool.java:272)
	at allaire.jrun.WorkerThread.run(../WorkerThread.java:75)

TIA - leo

------------
Leo Mendoza
lmendoza-at-garbersoft-dot-net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top