Solved

java http servlet response redirect not working for mapped drives

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

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Suggested Solutions

There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
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 video teaches viewers about errors in exception handling.
Suggested Courses

734 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