users@glassfish.java.net

Re: How do I access a file in .war from compiled jsp?

From: David Sanmartín <kienvaser_at_gmail.com>
Date: Wed, 3 Feb 2010 17:01:09 +0100

Sorry JO, but my idea only works with Struts.

On Wed, Feb 3, 2010 at 16:53, Sigal Shaharabani <
Sigal.Shaharabani_at_teledata-networks.com> wrote:

> To access a file which is in my archive I usually use the method
> getResourceAsStream which is part of java.lang.Class
>
> -----Original Message-----
> From: glassfish_at_javadesktop.org [mailto:glassfish_at_javadesktop.org]
> Sent: Wednesday, February 03, 2010 5:01 PM
> To: users_at_glassfish.dev.java.net
> Subject: How do I access a file in .war from compiled jsp?
>
> First Post.
>
> Hello all, I'm new with both Glassfish and jsp programming so bear with
> me if I seem to be missing something elementary.
>
> What I have is a simple application consisting of a jsp file that needs
> to access an XML document for editing. This document is stored along
> with the jsp in a WAR file that is deployed as a web application on
> glassfish.
>
> I can access the XML file directly by going to
> [i]http://localhost:8080/app_name/data/xmlFile.xml[/i], which is fine if
> I want to display data from the XML file; but I need to edit it
> directly.
>
> In order to do this it looks like I need to open it as a java File
> object and blah blah (I can make that work), however, opening it via a
> URL doesn't seem like the way to do that.
>
> This brings me to my question: how can I access the file directly (ie
> "C:/glassfish/domains/domain1/.../data/xmlFile.xml". this shouldn't be
> too hard, except that the data/xmlFile.xml is in a WAR file.
>
> I can get to the file using javascript by just going to
> "../data/xmlFile.xml".
>
> Let me know if you need any more clarification.
>
> Thanks in advance for any and all help!
>
> JO
> [Message sent by forum member 'jayo3434' (jayo3434_at_yahoo.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=384516
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>


-- 
David Sanmartín
www.david-sanmartin.net
Sent from Valencia, Comunidad Valenciana, España