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