Skip to Content
author's profile photo Former Member
Former Member

Customize output window

Hi,

I have this special piece of code that loads a specific document depending on the passed parameters of the URL. When it displays the document (a pdf), I would like the new window to be displayed without the address bar. Is that possible ? How may I do that ?

The aim of the application is to hide the path of the file that appears in the URL. By changing the numDoc value directly in the URL bar, I can access to ther files I am not suppose to see.

My code is:

BufferedReader br = null;
FileInputStream fileInputStream = null;
FileInputStream fileInputStream2 = null;
byte[] fileByteContent = null;
HttpServletResponse servletResponse = request.getServletResponse(true);
boolean fileExist = true;

String numDoc = request.getParameter("D");
String typeDoc = request.getParameter("T");
if (typeDoc.equalsIgnoreCase("1"))
	typeDoc = "D:\\Echanges\\Facture";
else	{ 
	if (typeDoc.equalsIgnoreCase("2"))
		typeDoc = "D:\\Echanges\\Certificats";
	else
		typeDoc="D:\\Echanges\\R3Documents";
}

int count = 0;
typeDoc = typeDoc + "\\" + numDoc + ".pdf";

//fileInputStream = new FileInputStream(typeDoc);  // Obtains input bytes from a file.

java.io.File myFile = new File(typeDoc);
if (myFile.exists() == false)	{
	//fileInputStream2 = new FileInputStream("D:\\Echanges\\undefined_certif.pdf");
	fileInputStream2 = new FileInputStream("D:\\Echanges\\errorDocAccess.htm");
	fileByteContent = new byte[fileInputStream2.available()]; // Assign size to byte array.
	while (fileInputStream2.available() > 0)	{
		// Correcting file content bytes, and put them into the byte array.
		fileByteContent[count] = (byte) fileInputStream2.read();
		count++;
	}
	servletResponse.setContentType("text/html");
	servletResponse.getOutputStream().write(fileByteContent);
}
else	{
	fileInputStream = new FileInputStream(typeDoc);
	fileByteContent = new byte[fileInputStream.available()]; // Assign size to byte array.
	while (fileInputStream.available() > 0)	{
		// Correcting file content bytes, and put them into the byte array.
		fileByteContent[count] = (byte) fileInputStream.read();
		count++;
	}
	servletResponse.setContentType("application/pdf");
	//code d'origine ---> servletResponse.getOutputStream().write(fileByteContent);
	servletResponse.getOutputStream().write(fileByteContent);
}

Thanks for your help.

Regards,

Thibault Schalck

Edited by: Thibault schalck on Oct 22, 2008 3:46 PM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 02:05 PM

    Hi,

    Use java script to do this.

    Regards

    Ayyapparaj

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 22, 2008 at 02:37 PM

    The problem is that it is a Visual Composer application that calls the java application and I have no idea where I can put some Javascript code to do that. My Java application is in a .par file.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.