Solved

java http servlet response redirect not working for mapped drives

Posted on 2008-09-29
2
1,169 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
2 Comments
 
LVL 1

Accepted Solution

by:
MrMarshall earned 500 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

813 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now