The "%" is a control character which needs to be urlEncoded. Browsers do this automatically for you and HttpServlet automatically un-encodes these characters for you when you use the getParameter method.
If your other apps are not encoding the data properly, then this is not really a servlet/Tomcat issue. Take a look at: http://www.php.net/urlencode. You may also want to look at: http://java.sun.com/j2se/1.4.2/docs/api/java/net/URLEncoder.html But if you aren't generating the posts from the Java app, there isn't a lot you can do on the receiving end. On Wednesday 19 May 2004 03:30 pm, [EMAIL PROTECTED] wrote: > Dear all, > I'm quite new using HttpServlets, that's why I hope you can help me! > I'm using an HttpServlet on Tomcat 5 that is prepared to receive POST HTTP > requests from remote machines. > > If I use an html form and I submit a text to this servlet (method post), > the get parameter of the http servlet returns the text content ok (with or > without the % character in the text). > > When this form, instead of submitting directly to the http servlet, submits > to another program in background (ex: a php program), which then does the > post to the servlet, the result is: > The get parameter returns null if the text has the % character (and so we > cannot see anything from the text). > > It is not a problem of the background program, because if the program posts > a simple php file, just to show the text contest, we can see the text ok, > even with the % character. This only happens if the program posts to the > this HTTPservlet. Furthermore, this problem happens also to other users who > wish to POST requests to this HTTP Servlet. Those users have their own > programs and in then they POST the text to our HTTP Servlet. > > Am I missing any important detail about char encoding? > > I'll send you an example of my HTTPServlet code to help you on the > troubleshooting. > > Hope you can help me!!! > Tiago > > ________________________________________________________________________ > public class teste extends HttpServlet { > > public void init(ServletConfig config) throws ServletException { > super.init(config); > > } > > public void destroy() { > > } > > > // HTTP <code>POST</code> method. > > protected void doPost(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException > { > > String text= request.getParameter("message"); > writeAnswer("TEXT: " + text ); > /* ---- Debug part --- > } > > /******** Aux Function********/ > > protected void writeAnswer(HttpServletRequest request, HttpServletResponse > response, String message) > throws ServletException, IOException { > response.setContentType("text/html"); > //response.setContentType("charset=ISO-8859-4"); > PrintWriter out = response.getWriter(); > out.println(Constants.BEGIN_HTML_PAGE); > out.println(message); > out.println(Constants.END_HTML_PAGE); > out.close(); > } > > }//end class > > Tiago > > __________________________________________________________ > Quanto gasta de Acesso � Internet? Fa�a as contas! > http://acesso.portugalmail.pt/contas > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] -- Ben Souther F.W. Davison & Company, Inc. This e-mail message, and any accompanying documents, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure, distribution or copying is prohibited. If you are not the intended recipient, please contact our office by email or by telephone at (508) 747-7261 and immediately destroy all copies of the original message. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] __________________________________________________________ Quanto gasta de Acesso � Internet? Fa�a as contas! http://acesso.portugalmail.pt/contas --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
