• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 304
  • Last Modified:

HttpServlet

I have a servlet which streams content to the brower using
response.setDateHeader("Last-Modified", DateUtils.now().getTime());
response.setHeader("Expires", "-1");
response.setContentType(contentTYpe);
response.setHeader("Content-Disposition", "attachment; filename=" +fileName);

I have an if condition which only does the above if there is content to stream. This content comes from the database.
If there is content it works as it should, ie displays a dialog window to open or save.

If there is no content then I just want to return from this servlet. What happens is that the browser points to this servlet

eg.

http://localhost:7001/cart/dowloadServlet

What i want is the original jsp to display where the user clicks to do the download.
Any ideas?
0
inzaghi
Asked:
inzaghi
  • 2
  • 2
2 Solutions
 
colr__Commented:
Can you not just redirect them to the original jsp url?

if (noContent){
response.sendRedirect("original.jsp");
return;
}
0
 
inzaghiAuthor Commented:
this would work but how come it does not automatically return control to the original jsp, similar to when you are asked to save/open the attachment.
0
 
girionisCommented:
This is probably be done because the jsp points to the servlet. You first go to the servlet, the browser sees that there is no content and it stays in the servlet.
0
 
colr__Commented:
If the original page is called original.jsp, then control should be returned to that page with the above code. The save/open dialogue should only appear if a file is abouyt to be downloaded, but since ther isnt one (in the case where there is no content), then you'll have to select a different file, am I right? Does original.jsp not do this?
0
 
girionisCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now