Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HttpServlet

Posted on 2006-06-27
5
Medium Priority
?
299 Views
Last Modified: 2011-04-14
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
Comment
Question by:inzaghi
[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
  • 2
5 Comments
 
LVL 8

Accepted Solution

by:
colr__ earned 1500 total points
ID: 16993910
Can you not just redirect them to the original jsp url?

if (noContent){
response.sendRedirect("original.jsp");
return;
}
0
 

Author Comment

by:inzaghi
ID: 16993939
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
 
LVL 35

Assisted Solution

by:girionis
girionis earned 500 total points
ID: 16999333
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
 
LVL 8

Expert Comment

by:colr__
ID: 16999343
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
 
LVL 35

Expert Comment

by:girionis
ID: 17000759
:)
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
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…
Suggested Courses

618 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