• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Servlet Response

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a jsp page, which have few links to download a file. Now when user clicks on those links a servlet is called say "downloadReport" servlet, which make a temporary file of that particular report, set the response type accordingly and write all the data to the stream. it is working fine to download the report and THAT JSP page remain visible. No change and no apparent submission of that page.

But the problem arises when there is some exception in the servlet. the jsp page disappear and there is servlet error msg. Now how can handle this?
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how do you handle exceptions in your servlet?
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
to my astonish, i haven't writen any try/catch clause. I just read the parameters i get from request, make the appropriate file through some other class (in which i have handled exceptions and return false to servlet if some occurs) ... The returned false status of file tell the servlet whether the file is ready to download or not. if it is then i make the stream and write it ... now what should i do if the return status is FALSE from the makeReportClass ???
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can implement "please wait..." mechanism here.

Searching the same or servlet forum with the string "please wait" would result in a number of threads discussing the same.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to decide who's fault it is.

If the user entered invalid parameters you should tell them which ones were invalid and ask them to correct them.

If there is an error at the server (maybe IOException) all you can do is show the user a friendly error message like "Unable to create report, please try again later".
 
Em Aiy
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
User has nothing to do with input. he just have to click on either of the links telling the report format (CSV/PDF/XLS) ... the javascript get the userclick option and submit the form at DownloadReport serlvet. (The jsp remain visible in the browser) ... now from DownloadReport i call Report class to generate the report ... if it is successfull it writes data onstream .. which make a download box appear at tha page to save the file (working fine)

Now if the report is not created (IOException) ... how can i manage to get the response of the JSP that is already been displayed to display some info there ??? I want to display the information at the same JSP file.
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic