Hi I think u have to use
res.setContentType("text/html"); and not
response.setContentType("text.html");

regards
RInaldo
[EMAIL PROTECTED]

-----Messaggio originale-----
Da: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]Per conto di Andi
Setiyadi
Inviato: lunedi 21 maggio 2001 21.58
A: [EMAIL PROTECTED]
Oggetto: 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

Reply via email to