Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Saving HTML file  RSS feed

 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello friends,

I am facing one problem in my current project. The scenario is as follows:-
(I am using Servlet 2.4 spec, Tomcat 4.14, jdk 1.4 and Struts 1.2)

Following abbr i have used:-
PL - Project List Page
SPO - Select Print Option Page
PDP - Project Detail Print Page

1) In one of the screens i display the list of projects (PL).
2) In this screen, an option is given to the user to select projects which he wants to print.
3) The user then selects, the projects he wants and selects the print option in a combo box provided in the screen and clicks on submit button.
4) The control is transferred to an Action class which displays a page (SPO) where in the user can select few more options related to the details of the projects selected needs to be printed.
5) The user selects his option and clicks on print button .... which triggers a POP-UP window, (PDP) where the user can see the details of the projects he has selected on the PL page.
6) Now, the user can select File->Print option of the browser to print the page.
7) Now in the POP-UP page i need to give functionality to the user to save the page he sees, as a file which he can view at later time. Using File-->Save As its somewhat possible in Firefox but not in IE.


So the flow is something like this :-

PL ---> SPO ----> PDP

....How can i let the user to save the page ? Please help me!
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please at least suggest me some work-arounds !
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean save as HTML? IE can do that as well.

(By the way, Tomcat 4 doesn't support Servlet API 2.4 - it uses 2.3. Make sure you're not inadvertently using features that were new in 2.4.)
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh so sorry....i am using 2.3 specification. Well, yes IE does give the facility to "Save As" html file....but when user opts for this facility and clicks on "Save As" ... an alert is prompted to the user saying "The file may not be saved correctly, Do you want to proceed?" and when i click on Yes, and proceed with saving....Actually, IE sends another request to the server, ...this can be seen with activity taking place in the console of Tomcat. Now, since i have opened a new Pop-Up window, i don't have the parameters, that will generate the same HTML file.....and hence it results in saving a user friendly error page of the project. And this should not happen !

I am not able to think of any solution to this problem.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why would a page in a popup window not have any required parameters? If you want the page to have parameters, then you need to add those to the URL.
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually.....when i click on Save in the Save as Dialogue Box, IE generates a request and posts the request.....this means, this particular thing is done by Browser, i do not have any control over that ...for example.....if it was any event like clicking of a hyperlink or button, i can always redirect my requests to the servlet or action i want to by specifying appropriate value in the action attribute of form tag and also the parameters i can send using, approriate method like, GET or POST....but since this time ...in our scenario ....browser is making the request i have no control over it.....THAT IS THE PROBLEM !
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see, when you said "popup window" you meant the Save dialog, not a window the web app had opened.

So the page being displayed is the direct result of a POST. That's something you should avoid anyway - you can use the PRG pattern for that. This article also talks about that a bit.
[ July 17, 2008: Message edited by: Ulf Dittmer ]
 
omkar patkar
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mmm ....well actually IT IS a new pop up window, let me explain the flow again : -

Project List Page ---> Select Print Option Page(Same IE Browser Window)---->Project Details Page(this is a New IE Window which is in fact a pop-up window) ... now in this new IE window, the HTML page i see ... needs to be saved. So when user goes for File --> Save As option in the IE browser window, he browses to the location in the local machine where he wants to save the file, and then clicks on the "Save" button. At this point of time as i have observed in the console, the browser places another request, even though there is no form tag or form elements in the page.


and i tried hard but did not get the PRG Pattern ...what it is ? .... pleae help me !
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So when user goes for File --> Save As option in the IE browser window, he browses to the location in the local machine where he wants to save the file, and then clicks on the "Save" button. At this point of time as i have observed in the console, the browser places another request, even though there is no form tag or form elements in the page.

This is where you lost me. It's a page that was opened when the user clicked a link on the main page. How can it be missing any of the parameters? If the popup window is the result of POST, then you should change it so that it's a GET, with all parameter passed in the URL. Then you'll have no problems with lost parameters.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!