Hello everyone,
i m designing a web site using jsp and i want to open any files like pdf . doc, etc in the browser without downloading it in the system, files are kept in the location(for eg .g://myfile.doc).
please suggest a feasible solution.

Is this web site for Intranet (local network often used in medium to large companies, or education institutions) purposes, because g://myfile.doc will not be valid location if on remote server

no its not for intranet , we are planning to launch in the internet. Currently it works in the LAN but some of the portion of the viewed file comes corrupted.we are downloading the file in the browser. I m using the following code

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="java.io.*" %>
  BufferedReader reader = null;
  String line;
  File file = new File("G://GlobalShare.doc");
  try {
      response.setContentLength((int) file.length());
     // response.setHeader("Content-Disposition","inline; filename=DSC01237.JPG");
      reader = new BufferedReader(new FileReader(file));
        while ((line = reader.readLine()) != null) {
  catch(FileNotFoundException fileNotFound) {
    out.print("The file does not exist.");
  catch(IOException ioErr) {
    out.print("An error occured during output.");
  finally {
        if (reader != null) {
This article has been dead for over six months. Start a new discussion instead.