This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Opening DOC files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Opening DOC files" Watch "Opening DOC files" New topic

Opening DOC files

El Durango

Joined: Oct 09, 2003
Posts: 23
I have a servlet which will open up a word document when given the URL for a doc file located on the server. However I would like it so that if the document URL is invalid it would display an HTML error page, however it still opens up Word and displays the error info there. I have a solution to this however it would require me to create a seperate JSP page to handle the errors. I am wondering can the servlet handle handle both Word docs and display error info on the browser.
I set the servlet content type to open up the responses in the MSWord app.
is there another way around this?? Do I have to redirect the response to a seperate JSP page to handle errors??
here is the line I mentioned:
Sudhir Howale

Joined: Aug 18, 2003
Posts: 4
Cant you set the response type depending on the validity of the URL. I mean to say, if you want to throw a normal HTML error page then you can not set the repsonse type as (application/msword).
I havent seen your code, but the flow should be
if(valid(URl) then { normal processing }
else ( set the response type as html and throw html error page }
Do write me , if i have misunderstood something...
Sudhir H
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Sudhir is saying that somehow you have to be able to determine if the URL is valid or not before attempting to open the word doc. Based on your posting, it seems like you are determining that the doc URL is invalid if the doc can not be found.

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: Opening DOC files
It's not a secret anymore!