File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet and Html Encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet and Html Encoding" Watch "Servlet and Html Encoding" New topic

Servlet and Html Encoding

Dharamvir (DV) Punia
Ranch Hand

Joined: Oct 04, 2004
Posts: 34
I have a jsp which uploads a file through a servlet, in Servlet when I
read the filename, its encoded. e.g
- original file name passed in jsp - dv_test.dec
- when i read in servlet after being submitted from jsp, the
name i get is dv_test.doc

So what's happending is "underscore" in filename is replaced with "_"

Below is what is in jsp header, I have tried without it still the same.
<%@ page
contentType="text/html; charset=UTF-8"
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">

The only thing I am doing different in JSP is setting the "enctype" in
form tag as shown below:
<form name="fileUploadForm2"
action="/FileUploaderDB2/DB2FileUploaderServlet" method="post"

Can someone tell me why this is happening and how it can be avoide.

I agree. Here's the link:
subject: Servlet and Html Encoding
Similar Threads
how to change content type from multipart/form-data to text/html
Apache commons UTF-8 problem.
JSP and HTML Encoding
Internationalization (specifically with Chinese characters)
UTF-8 encoding not honored when form has multipart/form-data