troubleshooting Question

Accessing JSP using WGET (timestamp option '-N')

Avatar of rnicholus
rnicholus asked on
JavaJSP
50 Comments1 Solution2422 ViewsLast Modified:
I have a JSP that serves file to our clients.  Please see code snippet.

We have a client using "WGET" utility to get the data.
It's working ok for this command:
wget --http-user=username --http-passwd=password 'http://....'

But now they want to use "-N" (timestamping) option:
wget -N --http-user=username --http-passwd=password 'http://....'

What they get is:
# HTTP request sent, awaiting response... 500 Internal Server Error  
# 14:30:56 ERROR 500: Internal Server Error.

I added this line but doesn't seem to help:
response.setHeader("Last-Modified", myFile.getLastModified());

Can someone please advise the best way to do this?
Thanks in advance for all the help.
String filename = ".....";
File myFile = new File(filename);	
BufferedInputStream in = new BufferedInputStream(
getServletContext().getResourceAsStream(filename));
	
response.setContentType(getServletContext().getMimeType(filename));
response.setHeader ("Content-Disposition", "attachment;filename=" + filename.replaceFirst(".+/(.+)", "$1"));
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 50 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 50 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros