views:

1120

answers:

4

I want to open a new browser and load a page from the file system (which will be created on clicking that button). My app is a java servlet. Basically I am allowing users to change some HTML on their website. On clicking the button the user get's to see a preview page, that shows what the page looks like with the changes made.

What would be the easiest way to do this and what issues can you see, and possibly how we would we get around them.

I see an issue, for example, if the browser window tries to open the file immediately, it won't even exist. So there needs to perhaps be some delay before trying to read the file.

+2  A: 

This can be done using java script

window.open('url','name',....)

you can pass parameters in this function.

google for "javascript window.open function"

Cheers

Ratnesh Maurya
+1  A: 

Hi,

Maybe you can use jQuery/AJAX or a similar technique to post the data to the server first and then open it in a new window.

see the jQuery documentation for an example: jQuery Post Example

Gaze
A: 

if there is not much data to pass for preview page, you may pass it as url params instead of using jQuery. If data is large it is better to use jQuery. :)

as http://www.xyz.com?name="name".....

Ratnesh Maurya
A: 

I'm not familliar with java servlets, but can't you keep the uploaded html in a server-side session variable, display the contents in your preview page, then save the contents of the variable out to the file system once the user accepts the changes ?

tsidwick