upload files in a directory

I want to upload files in a directory, for that I m using jsp:smart,the problem is I want to send the Authorization header along with therequest to upload the file send from the browser.There is no method provided in the HttpServletRequest.And I dont want to usehttp://username:password@m.../upload.jsp

How can I modify the request object before sedning it to theupload.jsp.

Actually when using this approachhttp://username:password@m.../upload.jsp doesnt work,1) MY first JSP sends the request to the second JSP that adds theusername and password(http://username:password@m.../upload.jsp ) and redirects thepage to the upload Jsp that requires Authorization header in herrequest to upload the file in the protected directory.

2) if i use jsp:forward and change the url to relative i.e<jsp:forward page ="username:password@u... "/> it does'ntworks. (Tomcat could not find the directory)

3) if I use response.sendRedirect("http://username:password@m.../upload.jsp"); it successfullyredirect the JSP but when I see the Headers list in the upload JSP ican not find the Authorization Header.

Share:

1 Answer Found

I don't think you will be able to accomplish what you are trying to dousing authorization headers because I don't think the request headersare mutable from within a servlet. The headers are supposed to besupplied by the client. Thus, you will have to prompt your client forauthorization. Is this a problem?

Why do you need the Authorization header anyhow? Is it a requirementfrom jsp:smart when the file is going to end up in a protecteddirectory?