users@glassfish.java.net

RE: where to place images in application using glassfish

From: Eve Pokua <gorgeous65_at_msn.com>
Date: Tue, 22 Sep 2009 19:35:21 +0100

Hassan,

 

Tomcat works differently to glassfish tough

 

here is what im doing-

 

 

 
In tomcat jsp are placed in the -
 
Installed - dir \tomcat\WORK\tomcat\ROOT
 
and servlets are placed -
 
E:\tomcat\WORK\tomcat\ROOT\web-inf\classes
 
that's how I do mine in tocat. Of cause, the tomcat
is a web server not a whole application server. I am
using glassfish.
 
Some body suggested placing in tomcat\Work\tomcat\ROOT\images
images being the folder containing the images
and ROOT would contain jsps.
 

 
so construct as-
 
> <display:column>
> <img src="../images/${bpic}"/>
> </display:column>

 
in the database the string menjeans.png is contained in the table attribute.
 
But in glassfish, as you may already know it works like this:

 
I have created a project folder / dir using netbeans as e.g
Enterappli
 
Now my jsp files are in:-
 
dir\Enterappli\Enterappli-war\web\viewapp.jsp
 
my servlets are in-

dir\Enterappli\Enterappli-war\src\java\myservletfiles\myservletcontrol.java
 
Now I have my images folder in-
 
Enterappli\Enterappli-war\images
 
im the attribute on my table in the DB, I've
 
menjeans.png
 
which is a string.
 
my servlet invoke the bean and forward data to my jsp as
in the case of MVC design.
 
Ok now my jsp already display the data except the pic.
 
So how do I construct it:
 
<display:column><img border="1" src="../images/${bpic}" height="200" width="200" title="Picture"/></display:column>
 
bpic is an attribute of my table in the database.
 
Pls, any suggestion.
 
Thanking you in advance.
 
eve
 
> Date: Tue, 22 Sep 2009 08:11:26 -0700
> From: hassan.schroeder_at_gmail.com
> To: users_at_glassfish.dev.java.net
> Subject: Re: where to place images in application using glassfish
>
> On Tue, Sep 22, 2009 at 7:39 AM, Eve Pokua <gorgeous65_at_msn.com> wrote:
>
> > In tomcat, i would do something like the following:
>
> > if your jsp page is at /ROOT/jsps/mydisply.jsp and images
> > are in /ROOT/images I can construct a <display:column> tag:
> >
> > <display:column>
> > <img src="../images/${bpic}"/>
> > </display:column>
>
> That should be an absolute path ( drop the leading ".."). And it
> really should include the context path, though if this is the ROOT
> context it's not essential.
>
> > Now where to I place my images using glassfish.
>
> Exactly the same place as using Tomcat.
>
> > I assum in my web-inf folder of my application
> >
> > then I can access it as follows:
>
> > <display:column><img border="1" src="/WEB-INF/${bpic}" height="200"
> > width="200" title="Bale Picture"/></display:column>
>
> No, then as you've discovered, no one will be able to see them --
> files in WEB-INF are protected from direct access, which a browser
> needs in order to fetch them. That's part of the Servlet Spec.
>
> --
> Hassan Schroeder ------------------------ hassan.schroeder_at_gmail.com
> twitter: @hassan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
                                                _________________________________________________________________ Get the best of MSN on your mobile http://clk.atdmt.com/UKM/go/147991039/direct/01/
--_3d9b7dc8-2fe2-41c8-8750-e543eda405fc_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hassan,<BR>
&nbsp;<BR>
Tomcat works differently to glassfish tough<BR>
&nbsp;<BR>
here is&nbsp;what im doing-<BR>
&nbsp;<BR>
&nbsp;<BR>
&nbsp;<BR>In tomcat jsp are&nbsp;placed in the -<BR>&nbsp;<BR>Installed - dir \tomcat\WORK\tomcat\ROOT<BR>&nbsp;<BR>and servlets are placed -<BR>&nbsp;<BR>E:\tomcat\WORK\tomcat\ROOT\web-inf\classes<BR>&nbsp;<BR>that's how I do mine in tocat.&nbsp; Of cause, the&nbsp;tomcat<BR>is a web server&nbsp;not a whole application server.&nbsp; I am<BR>using glassfish.<BR>&nbsp;<BR>Some body suggested placing in tomcat\Work\tomcat\ROOT\images<BR>images being the folder containing the images<BR>and ROOT would contain jsps.<BR>&nbsp;<BR><BR>&nbsp;<BR>so construct as-<BR>&nbsp;<BR>&gt; &lt;display:column&gt;<BR>&gt; &lt;img src="../images/${bpic}"/&gt;<BR>&gt; &lt;/display:column&gt;<BR><BR>&nbsp;<BR>in the database the string menjeans.png&nbsp;is contained in the table attribute.<BR>&nbsp;<BR>But in glassfish, as you may already know it works like this:<BR><BR>&nbsp;<BR>I&nbsp;have created&nbsp;a project folder / dir using netbeans as e.g<BR>Enterappli<BR>&nbsp;<BR>Now my jsp files are in:-<BR>&nbsp;<BR>dir\Enterappli\Enterappli-war\web\viewapp.jsp<BR>&nbsp;<BR>my servlets are in-<BR><BR>dir\Enterappli\Enterappli-war\src\java\myservletfiles\myservletcontrol.java<BR>&nbsp;<BR>Now I have my images folder in-<BR>&nbsp;<BR>Enterappli\Enterappli-war\images<BR>&nbsp;<BR>im&nbsp;the attribute on my&nbsp;table in the DB, I've<BR>&nbsp;<BR>menjeans.png<BR>&nbsp;<BR>which is a string.<BR>&nbsp;<BR>my servlet invoke the&nbsp;bean and forward data to my jsp as <BR>in the case of MVC&nbsp;design.<BR>&nbsp;<BR>Ok now&nbsp;my jsp already display the data except the pic.<BR>&nbsp;<BR>So how do I construct it:<BR>&nbsp;<BR>&lt;display:column&gt;&lt;img border="1" src="../images/${bpic}" height="200" width="200"&nbsp; title="Picture"/&gt;&lt;/display:column&gt;<BR>&nbsp;<BR>bpic is an attribute of my table in the database.<BR>&nbsp;<BR>Pls, any suggestion. <BR>&nbsp;<BR>Thanking you in advance.<BR>&nbsp;<BR>eve<BR>&nbsp;<BR>&gt; Date: Tue, 22 Sep 2009 08:11:26 -0700<BR>&gt; From: hassan.schroeder@gmail.com<BR>&gt; To: users@glassfish.dev.java.net<BR>&gt; Subject: Re: where to place images in application using glassfish<BR>&gt; <BR>&gt; On Tue, Sep 22, 2009 at 7:39 AM, Eve Pokua &lt;gorgeous65@msn.com&gt; wrote:<BR>&gt; <BR>&gt; &gt; In tomcat, i would do something like the following:<BR>&gt; <BR>&gt; &gt; if your jsp page is at /ROOT/jsps/mydisply.jsp and images<BR>&gt; &gt; are in /ROOT/images&nbsp;I can construct a &lt;display:column&gt; tag:<BR>&gt; &gt;<BR>&gt; &gt; &lt;display:column&gt;<BR>&gt; &gt; &lt;img src="../images/${bpic}"/&gt;<BR>&gt; &gt; &lt;/display:column&gt;<BR>&gt; <BR>&gt; That should be an absolute path ( drop the leading ".."). And it<BR>&gt; really should include the context path, though if this is the ROOT<BR>&gt; context it's not essential.<BR>&gt; <BR>&gt; &gt; Now where to I place my images using glassfish.<BR>&gt; <BR>&gt; Exactly the same place as using Tomcat.<BR>&gt; <BR>&gt; &gt; I assum in my web-inf folder of my application<BR>&gt; &gt;<BR>&gt; &gt; then I can access it as follows:<BR>&gt; <BR>&gt; &gt; &lt;display:column&gt;&lt;img border="1" src="/WEB-INF/${bpic}" height="200"<BR>&gt; &gt; width="200"&nbsp; title="Bale Picture"/&gt;&lt;/display:column&gt;<BR>&gt; <BR>&gt; No, then as you've discovered, no one will be able to see them --<BR>&gt; files in WEB-INF are protected from direct access, which a browser<BR>&gt; needs in order to fetch them. That's part of the Servlet Spec.<BR>&gt; <BR>&gt; -- <BR>&gt; Hassan Schroeder ------------------------ hassan.schroeder@gmail.com<BR>&gt; twitter: @hassan<BR>&gt; <BR>&gt; ---------------------------------------------------------------------<BR>&gt; To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net<BR>&gt; For additional commands, e-mail: users-help@glassfish.dev.java.net<BR>&gt; <BR> <br /><hr />Beyond Hotmail - see what else you can do with Windows Live. <a href='http://clk.atdmt.com/UKM/go/134665375/direct/01/' target='_new'>Find out more.</a></body>
</html>
--_3d9b7dc8-2fe2-41c8-8750-e543eda405fc_--