Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

java http servlet response redirect not working for mapped drives

Posted on 2008-09-29
2
Medium Priority
?
1,194 Views
Last Modified: 2013-12-02
Hi
  I am using tomcat and would like to redirect my servlet to a particular file server location after some validations.My file server is say mapped at X:\test.I am trying to use response.sendRedirect("file:///X:\test").But that doesnt work.It doesnt throw any exceptions at the backend but gives a page not displayed error.Evne if I try a "file:\\c:\\" on my local box , I get this error.I initially thought it would have to do with permissions but since I cant even access my local box , I guess the problem is something else.Can you please help?
Thanks
0
Comment
Question by:res_this
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
MrMarshall earned 1500 total points
ID: 22599757
A HTTP Redirect is a command that tells the browser that it is being redirected to a new URL this differs from a Forward which simply forwards the Browsers request to a new Url without informing the Browser.

However, since the browser is involved the location needs to be accessible by the Browser and relative to the server.

It sounds like you want to return the file to the Browser as a response to the request. You should look into writing the file to the output stream.
i.e. See Code Attached.

Hope this helps.



	
 
        FileInputStream in=new FileInputStream("X:\\Test");
    	byte[] buffer=new byte[1024];
    	int count=0;
    	OutputStream out=	response.getOutputStream();
    	while((count=in.read(buffer))!=-1){
    		out.write(buffer);
    	}
    	

Open in new window

0
 

Author Comment

by:res_this
ID: 22600043
Hi,
    Thanks , but I dont have to display the file contents.The idea is the viewer should be able to navigate
the X://test folder and be able to view its contents.
Thanks
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
This article is about some of the basic and important steps to be used to improve the performance in web-sphere commerce application development. 1) Always leverage the Dyna-caching facility provided by the product 2) Remove the unwanted code …
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question