Java Servlet getParameter for a param that is a URL

后端 未结 1 714
时光取名叫无心
时光取名叫无心 2021-02-08 10:39

I am building a site which submits a url to a servlet for analysis purposes. On the client side, I submit the url as a parameter that is encoded. For example...

         


        
1条回答
  •  一整个雨季
    2021-02-08 11:10

    I can't reproduce your problem on Tomcat 6.0.29. There's more at matter. Maybe a Filter in the chain which is doing something with the request object?

    Anyway, here's a SSCCE in flavor of a single JSP:

    
    
        
            Test
        
        
            

    click here

    URL: ${param.url}

    Copy'n'paste'n'run it and click the link. Right here I see the following result:

    click here

    URL: http://www.site.com?param1=1¶m2=2

    The same is reproducible with a simple servlet like this which is invoked directly by browser address bar:

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().write(request.getParameter("url"));
    }
    

    Tomcat is by the way configured with URIEncoding="UTF-8" in HTTP connector, but even with ISO-8859-1 (which is the default), the behaviour is -as expected in this particular case- the same.

    0 讨论(0)
提交回复
热议问题