Solved

java http servlet response redirect not working for mapped drives

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

728 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

12 Experts available now in Live!

Get 1:1 Help Now