You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Poggenpohl, Daniel" <Da...@isst.fraunhofer.de> on 2015/03/23 23:50:11 UTC

Can't access generate HTML file (probably not Tapestry-specific)

Hello,

perhaps you people can help me...my application has various resources deployed. Among them are a kind of HTML template files. I take the files, replace part of the contents of the file according to a certain syntax, and want to display the resulting html file in an iframe on a Tapestry page.

To do this, I am currently creating temporary html files. I use the createTempFile method of java.nio.Files. Those temporary files are thus stored locally on each user's pc. But when I want to display the generated HTML file, I have to use File://<File:///\\> as a prefix, which probably doesn't work with my browser.

How would you create temporary files inside the servlet container so that you could access them using ServletContext or whatever necessary?

Regards,
Daniel

--
Dipl. Inf. Daniel Poggenpohl, Fraunhofer-Institut für Software- und Systemtechnik ISST
Compliance- und Sicherheitslösungen
Emil-Figge-Straße 91, 44227 Dortmund, Germany
Telefon: +49 (0) 231 / 9 76 77-323
mailto: Daniel.Poggenpohl@isst.fraunhofer.de<ma...@isst.fraunhofer.de>
http://www.isst.fraunhofer.de<http://www.isst.fraunhofer.de/>


Re: Can't access generate HTML file (probably not Tapestry-specific)

Posted by Lance Java <la...@googlemail.com>.
I don't really understand why you need the temp files? The normal approach
is to store the static template files somewhere (classpath or database etc)
but never actually store the merge results (template merged with context).

I think you should provide a page which returns a StreamResult which is the
merged html and serve that page in your iframe. No temp files needed, just
generate on the fly.

If you decide you want to cache the results to disk, use one of the many
cache implementations out there rather than rolling your own.
On 23 Mar 2015 22:51, "Poggenpohl, Daniel" <
Daniel.Poggenpohl@isst.fraunhofer.de> wrote:

> Hello,
>
> perhaps you people can help me...my application has various resources
> deployed. Among them are a kind of HTML template files. I take the files,
> replace part of the contents of the file according to a certain syntax, and
> want to display the resulting html file in an iframe on a Tapestry page.
>
> To do this, I am currently creating temporary html files. I use the
> createTempFile method of java.nio.Files. Those temporary files are thus
> stored locally on each user's pc. But when I want to display the generated
> HTML file, I have to use File://<File:///\\> as a prefix, which probably
> doesn't work with my browser.
>
> How would you create temporary files inside the servlet container so that
> you could access them using ServletContext or whatever necessary?
>
> Regards,
> Daniel
>
> --
> Dipl. Inf. Daniel Poggenpohl, Fraunhofer-Institut für Software- und
> Systemtechnik ISST
> Compliance- und Sicherheitslösungen
> Emil-Figge-Straße 91, 44227 Dortmund, Germany
> Telefon: +49 (0) 231 / 9 76 77-323
> mailto: Daniel.Poggenpohl@isst.fraunhofer.de<mailto:
> Daniel.Poggenpohl@isst.fraunhofer.de>
> http://www.isst.fraunhofer.de<http://www.isst.fraunhofer.de/>
>
>

Re: Can't access generate HTML file (probably not Tapestry-specific)

Posted by Geoff Callender <ge...@gmail.com>.
Server-side, in a Tapestry page or service, create the file.

		final File htmlTempFile = File.createTempFile("htmlTemp", ".html");
		htmlTempFile.deleteOnExit();

Then manipulate it. If you need to know its path, it's no problem...

		String htmlTempPath = htmlTempFile.getAbsolutePath();

...but don't return the path to the client - that would be bad form.

Geoff

On 24 Mar 2015, at 9:50 am, Poggenpohl, Daniel <Da...@isst.fraunhofer.de> wrote:

> Hello,
> 
> perhaps you people can help me...my application has various resources deployed. Among them are a kind of HTML template files. I take the files, replace part of the contents of the file according to a certain syntax, and want to display the resulting html file in an iframe on a Tapestry page.
> 
> To do this, I am currently creating temporary html files. I use the createTempFile method of java.nio.Files. Those temporary files are thus stored locally on each user's pc. But when I want to display the generated HTML file, I have to use File://<File:///\\> as a prefix, which probably doesn't work with my browser.
> 
> How would you create temporary files inside the servlet container so that you could access them using ServletContext or whatever necessary?
> 
> Regards,
> Daniel
> 
> --
> Dipl. Inf. Daniel Poggenpohl, Fraunhofer-Institut für Software- und Systemtechnik ISST
> Compliance- und Sicherheitslösungen
> Emil-Figge-Straße 91, 44227 Dortmund, Germany
> Telefon: +49 (0) 231 / 9 76 77-323
> mailto: Daniel.Poggenpohl@isst.fraunhofer.de<ma...@isst.fraunhofer.de>
> http://www.isst.fraunhofer.de<http://www.isst.fraunhofer.de/>
> 


Re: Can't access generate HTML file (probably not Tapestry-specific)

Posted by Stephan Windmüller <wi...@white-hawk.de>.
On 23.03.2015, Daniel Poggenpohl wrote:

> perhaps you people can help me...my application has various 
> resources deployed. Among them are a kind of HTML template files. I
> take the files, replace part of the contents of the file according to
> a certain syntax, and want to display the resulting html file in an
> iframe on a Tapestry page.
> 
> To do this, I am currently creating temporary html files.

Do you really need an iframe? If you are able to put the parsed result
in a string, just output it using the raw component:

http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/corelib/components/OutputRaw.html

- Stephan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org