users@glassfish.java.net

Re: URL Encoded Query String Wrong

From: <Jan.Luehe_at_Sun.COM>
Date: Fri, 06 Jul 2007 15:25:45 -0700

Hi ITVGuy,


ITVGuy2000 wrote:

>Thank you for looking.
>
>I have dropped the war file you provided into the autodeploy directory, and
>run the app. The results are as you say, and as expected.
>
>Looking at the files within the war file, I notice one subtle difference.
>The line in the index.jsp of your war file is:
><FORM METHOD="GET" ACTION=?/TestJSPForm?>
>instead of, as in the file I created:
><FORM METHOD="GET" ACTION="/TestJSPForm">
>I have since experimented and realize the following all "work":
><FORM METHOD="GET" ACTION="/TestJSPForm/">
><FORM METHOD="GET" ACTION="/TestJSPForm/.">
><FORM METHOD="GET" ACTION="/TestJSPForm/index.jsp">
><FORM METHOD="GET">
>In fact the only form that results in the mangled URL is the form I chose:
><FORM METHOD="GET" ACTION="/TestJSPForm">
>
>As far as I understand things, "/TestJSPForm" is a valid URL.
>
>
>Also, I am unfamiliar with the ?/TestJSPForm? form of a URL. And I confirmed
>that they are actually question marks (rather than some encoded character)
>by typing them into my editor directly.
>
>So my questions are as follows:
>Why does the "/TestJSPForm" action result an incorrectly encoded URL query
>string?
>Why does the ?/TestJSPForm? action work at all?
>If the URL "/TestJSPForm" is invalid, shouldn't it result in an exception
>rather than incorrectly encoded URL?
>
>

Thanks for filing this issue:

https://glassfish.dev.java.net/issues/show_bug.cgi?id=3085

I just committed a fix for it to GlassFish v2, which will be available
in the upcoming b55, and also updated the above issue link
with my evaluation.


Jan

>One more observation. With the "/TestJSPForm" form of the action, I tried
>all variations of locales, character encoding, and form-hints. I also tried
>including the JSTL formatting for locale and character encoding. Nothing
>seemed to have any impact on the URL encoding of this string.
>
>I can move on and deploy my simple JSP example app to SJAS using one of the
>other forms that works, so my immediate problem is solved, but still it
>seems something is goofed in glassfish.
>
>ITVGuy
>
>
>Jan.Luehe wrote:
>
>
>>ITVGuy2000 wrote:
>>
>>
>>
>>>I have a very simple JSP application that runs perfectly on Tomcat, but
>>>
>>>
>won’t
>
>
>>>run correctly on glassfish. I am guessing I have messed up some
>>>configuration for the web application, but I am not sure where.
>>>
>>>The JSP simply presents a form first time through, the subsequently (after
>>>submitted) displays the parameters to the page.
>>>
>>>When I run this application on glassfish, I get a 404-The requested
>>>
>>>
>resource
>
>
>>>() is not available. The problem seems to be that the query string is
>>>
>>>
>being
>
>
>>>incorrectly encoded.
>>>
>>>
>>>When I look at the address line of my browser I see:
>>>http://localhost:8081/JSPForm/%3fTerm%3dblah%26Definition%3dblah%250D%250A%26submit%3dProcess
>>>rather than:
>>>http://localhost:8081/JSPForm/?Term=blah&Definition=blah&submit=Process
>>>If I in fact type this query string by hand into the address line, my JSP
>>>happily displays the results blah and blah.
>>>
>>>
>>>
>>>
>>I'm unable to reproduce this.
>>
>>I've bundled your resources into the attached WAR.
>>After deploying it, I can access the form and see the entered
>>values listed.
>>
>>The only difference between Tomcat and GlassFish that I am aware of is
>>the default URI encoding: GlassFish uses UTF-8, whereas Tomcat uses
>>ISO-8859-1.
>>
>>We changed the default in GlassFish to UTF-8 in an effort to fix:
>>
>>https://glassfish.dev.java.net/issues/show_bug.cgi?id=2339
>>("i18n: deployed app doesn't launch")
>>
>>
>>Jan
>>
>>
>>
>>>I am guessing this has to do with document/page/parameter encoding, but I
>>>
>>>
>am
>
>
>>>not sure where I have this configured wrong. I am utilizing the default
>>>web.xml and web-app.xml generated by NetBeans. I have tried setting the
>>>default character set encoding in the sun-web.xml to both ‘UTF-8’ and to
>>>‘ISO-8859-1’ with no effect.
>>>
>>>Am I doing something wrong, or is this a bug?
>>>
>>>ITVGuy2000
>>>
>>>---------------- index.jsp ---------------
>>>
>>><%_at_page contentType="text/html"%>
>>><%_at_page pageEncoding="UTF-8"%>
>>><%_at_page import="java.util.*"%>
>>>
>>><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>>> "http://www.w3.org/TR/html4/loose.dtd">
>>>
>>><html>
>>> <head>
>>> <meta http-equiv="Content-Type" content="text/html;
>>>charset=UTF-8">
>>> <title>TestJSPForm</title>
>>> </head>
>>> <body>
>>>
>>> <center>
>>> <h1>TestJSPForm</h1>
>>> Today's date is: <%= new Date() %>
>>> </center>
>>> <%
>>> if (request.getParameter("Term") == null &&
>>>request.getParameter("Definition")
>>> == null)
>>> {
>>> %>
>>> <CENTER>
>>> <H2>Glossary Info Form</H2>
>>> <FORM METHOD="GET" ACTION=”/TestJSPForm”>
>>> <table width="300" border="0">
>>> <tr>
>>> <td width="122">Term: </td>
>>> <td width="168"><input type="text" name="Term"
>>>size=40></td>
>>> </tr>
>>> <tr>
>>> <td> Definition: </td>
>>> <td><textarea name="Definition"
>>>cols="40"></textarea></td>
>>> </tr>
>>> <tr>
>>> <td colspan="2">&nbsp;</td>
>>> </tr>
>>> <tr>
>>> <td colspan="2"><div align="center">
>>> <input name="submit" type="submit"
>>>value="Process">
>>> </div></td>
>>> </tr>
>>> </table>
>>> </FORM>
>>> </CENTER>
>>> <%
>>> }
>>> else
>>> {
>>> %>
>>> <P align="center">
>>> The Glossary Entry you have provided:
>>> <P align="center"> <table width="482" border="0"
>>>align="center">
>>> <tr valign="top">
>>> <td width="140">Term:</td>
>>> <td width="332"><%= request.getParameter("Term") %></td>
>>> </tr>
>>> <tr valign="top">
>>> <td><P align="left">Definition: </td>
>>> <td><%= request.getParameter("Definition") %></td>
>>> </tr>
>>> </table>
>>> <% } %>
>>> </body>
>>></html>
>>>
>>>------------------- sun-web.xml ----------------------
>>>
>>><?xml version="1.0" encoding="UTF-8"?>
>>><!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application
>>>Server 9.0 Servlet 2.5//EN"
>>>"http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
>>><sun-web-app error-url="">
>>> <context-root>/TestJSPForm</context-root>
>>> <class-loader delegate="true"/>
>>> <jsp-config>
>>> <property name="classdebuginfo" value="true">
>>> <description>Enable debug info compilation in the generated servlet
>>>class</description>
>>> </property>
>>> <property name="mappedfile" value="true">
>>> <description>Maintain a one-to-one correspondence between static
>>>content and the generated servlet class' java code</description>
>>> </property>
>>> </jsp-config>
>>></sun-web-app>
>>>
>>>------------------- web.xml ----------------------------
>>>
>>><?xml version="1.0" encoding="UTF-8"?>
>>>
>>><web-app xmlns="http://java.sun.com/xml/ns/javaee"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>>>http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>>> version="2.5">
>>> <session-config>
>>> <session-timeout>
>>> 30
>>> </session-timeout>
>>> </session-config>
>>> <welcome-file-list>
>>> <welcome-file>
>>> index.jsp
>>> </welcome-file>
>>> </welcome-file-list>
>>></web-app>
>>>
>>>
>>>
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
>>For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>>
>>
>>
>
>
>