Andi:
You have called HttpServletResponse.setContentType with the parameter
"text.html". This is not a valid browser presentable file type. I think what
you meant to use was "text/html" which is the valid content type of HTML pages.
Jason Coward
Technical Relationship Manager
Mongoose Technology, Incorporated
[EMAIL PROTECTED]
http://www.mongoosetech.com
| -----Original Message-----
| From: A mailing list for discussion about Sun Microsystem's Java Servlet
| API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Andi
| Setiyadi
| Sent: Monday, May 21, 2001 2:58 PM
| To: [EMAIL PROTECTED]
| Subject: reading and edit document on the fly in servlet
|
|
| Hi,
| I have a servlet that its main job is to call htm documents and edit the
| contents on the fly before display the documents to the users.
| I tried to use the following code:
|
|
| import ...
|
| public class PersonnetDocContents extends HttpServlet {
| public void doGet(HttpServletRequest req, HttpServletResponse res)
| throws ServletException, IOException {
| int i;
| String path = "";
| String docContent = "";
| String docID = req.getParameter("docID"); //16 digit id
| BufferedReader buffer = null;
|
| res.setContentType("text.html");
| PrintWriter out = res.getWriter();
|
| for(i=1 ; i<4 ; i++) //each 4 ids
| represent a folder name
| {
| path = path + docID.substring(0,4) + "/";
| docID = docID.substring(4);
| }
|
| path = "/docs/" + path + docID + ".htm";
| URL docs = new URL("http://myhostname/pnet" + path);
| URLConnection docsConnection = docs.openConnection();
|
| buffer = new BufferedReader(new
| InputStreamReader(docsConnection.getInputStream()));
| docContent = buffer.readLine();
| buffer.close();
|
| out.println(docContent);
| }
| }
|
|
| The problem is, when users click a link to open a documents, it is not
| displaying the contents, instead it will launch a window and ask the users
| to save it (as if users try to download it).
| Any thought why? Am using the right way in order to read and edit the
| content on the fly?
| Thank you.
|
| Andi Setiyadi
|
| ___________________________________________________________________________
| To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
| of the message "signoff SERVLET-INTEREST".
|
| Archives: http://archives.java.sun.com/archives/servlet-interest.html
| Resources: http://java.sun.com/products/servlet/external-resources.html
| LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
|
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html