mukhar thanks for your reply.
i tried your code on a windows  95 machine with servletrunner utility it
worked . but when i tried the same on javawebserver it says that it is not
able to locate the file. i put it in public_html which is my document root
directory. i wanted to use this code  to return a menu (html page) after
checking the user name and password  in the servlet which is called by the
action performed in the login page. when i generated the menu dynamically
from servlet it is working. you also told about sending redirect to static
file's Url please elaborate this a bit.
thanks in advance
rajavardhan
-----Original Message-----
From: Kevin Mukhar <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Tuesday, February 01, 2000 8:17 AM
Subject: Re: OPENING HTML FILE FROM A SERVLET


rajavardhan wrote:
>
> hi friends
>                    iam new to servlets.
>                    i know how to generate a html file dynamically from a
> servlet.  But i want  to open a static html file in the browser and
control
> should be transfered to that file.  i have tried it with requestdispatcher
> but it din't worked for me.

Because a static html file is just a file of text, you can't transfer
control to
it. You just need to change your mindset: you're trying to open a file and
send
the contents of that file to the client. Here's a quick and dirty way:

  BufferedReader br = new BufferedReader(new FileReader("aFileName");
  File file = new File("aFileName");
  int buffer_size = file.length();
  char[] c = new char[buffer_size];
  br.read(c, 0, buffer_size);
  String contents = new String(c);
  br.close();

  response.setContentType("text/html");
  PrintStream out = new PrintStream(response.getOutputStream());
  out.print(contents);
  out.close();

Since it's a static file, you could also send a redirect to the static
file's
URL.

K Mukhar

___________________________________________________________________________
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