Skip to main content

Cannot display image from form-based login jsp

15 replies [Last post]
henryliu
Offline
Joined: 2009-08-05

Hi, Dear:

Would you please advise me how to display an image from form-based login jsp?

I coded a form-based login jsp and it works fine and allow me to login (I already did all setups). However the login jsp cannot display the image which I put in the jsp.

The login jsp is coded like following:

Logon

User ID:

Password:

-->

---------------------------------------------
The file structure is like this:
AISWeb\WebContent\login.jsp
AISWeb\WebContent\images
--------------------------------------------

When the .ear file is deployed on GlassFish, the files are deployed as following:

C:\Sun\SDK\domains\domain1\applications\j2ee-apps\AIS\AISWeb_war\login.jsp

C:\Sun\SDK\domains\domain1\applications\j2ee-apps\AIS\AISWeb_war\images

I am guessing that the login jsp cannot find the directory of images.

Even I changed as

-->

it still does not work and cannot display the image.

Does anyone have any idea or experience o that? Please help me on that.

Thank you very much.

Henry

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Hassan Schroeder

On Thu, Aug 6, 2009 at 10:47 AM, wrote:

> The home page jsp has to be relative path (src="images/eah_banner_logo.gif").

So -- one more time -- what is the COMPLETE PATH you see
when you view JUST THAT IMAGE? as in

http://example.com/foobar/images/eah_banner_logo.gif

> By the way, what is "FF" in your post `view image` (right-click menu in FF)?

FireFox

> Anyway how to make the login jsp display the image?

Put the right path in. Which you'll have if you do as I've suggested.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

henryliu
Offline
Joined: 2009-08-05

For http://example.com/foobar/images/eah_banner_logo.gif

its complete path is "/foobar/images/eah_banner_logo.gif", is that right?

I don't have FireFox

I like to try your idea:
url encoding of all your links via the JSTL standard lib.

Would you please tell me how to do that way?

Hassan Schroeder

On Thu, Aug 6, 2009 at 11:27 AM, wrote:
> For http://example.com/foobar/images/eah_banner_logo.gif
>
> its complete path is "/foobar/images/eah_banner_logo.gif", is that right?

Yes. Have you looked at the two image paths in question?

> I don't have FireFox

? I don't know how anyone doing web development can *not* have
Firefox with the web developer and firebug plugins, but whatever.

> I like to  try your idea:
> url encoding of all your links via the JSTL standard lib.

The effect is the same as this
src="<%=request.getContextPath()%>/images/eah_banner_logo.gif"
which was already suggested, so if that didn't work, using the JSTL
won't help this problem.

> Would you please tell me how to do that way?

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

ggierer
Offline
Joined: 2007-12-09

try this:

this will fix any context path issues (if this is the cause)

henryliu
Offline
Joined: 2009-08-05

Thank you very much guys.

I tried this:

It can find the context path. It is good.

However it still cannot display the image. The interesting thing is that when the same login jsp is deployed on IBM WebSphere server it works fine and can display the image. But the same login jsp cannot display the image when deployed on GlassFish server.

I found the difference of deployed structures between GlassFish and WebSphere:
The root war file structure is AISWeb.
On the WebSphere it is deployed as AISWeb.war
On the GlassFish it is deployed as AISWeb_war.

I am not sure this causes the problem or not.
I am guessing it is because the GlassFish server cannot find the source of the image file.

I tried to find a example of form-based login jsp with an image. But I could not find anyone.

Would you provide me a example of form-based login jsp with an image?

Thanks a lot.

Hassan Schroeder

On Thu, Aug 6, 2009 at 7:42 AM, wrote:

Again, stop guessing by looking at the file system.

Do `view source` *in a browser* of the page that works and the one
that doesn't. Post the image URLs.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

henryliu
Offline
Joined: 2009-08-05

That is:

The login jsp which doesn’t work:

The home page that works after login:

So it is the same.

Hassan Schroeder

On Thu, Aug 6, 2009 at 8:56 AM, wrote:

> The login jsp which doesn’t work:

> View-> source:

> The home page that works after login:

> View->source:

> So it is the same.

?? So obviously it is *not* the same -- one is absolute, one is not.

And if you use `view image` (right-click menu in FF) or equivalent
you will see how those URLs are being constructed.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

henryliu
Offline
Joined: 2009-08-05

Yes, I realized they are not same.

I tried different combinations. Neither relative(src="images/eah_banner_logo.gif") nor absolute (src="/images/eah_banner_logo.gif") path for login jsp can work.

The home page jsp has to be relative path (src="images/eah_banner_logo.gif").

By the way, what is "FF" in your post `view image` (right-click menu in FF)?

Anyway how to make the login jsp display the image?

Martin Gainty

this is my config
$GLASSFISH_HOME/domains/domain1/applications/j2ee-modules/hello
login.jsp contains:

Hello

where location of duke.waving.gif is
$GLASSFISH_HOME/domains/domain1/applications/j2ee-modules/hello/image/duke.waving.gif

so relative pathing for src attribute of

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité

Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

> Date: Thu, 6 Aug 2009 10:47:47 -0700
> From: glassfish@javadesktop.org
> To: users@glassfish.dev.java.net
> Subject: Re: Cannot display image from form-based login jsp
>
> Yes, I realized they are not same.
>
> I tried different combinations. Neither relative(src="images/eah_banner_logo.gif") nor absolute (src="/images/eah_banner_logo.gif") path for login jsp can work.
>
> The home page jsp has to be relative path (src="images/eah_banner_logo.gif").
>
> By the way, what is "FF" in your post `view image` (right-click menu in FF)?
>
> Anyway how to make the login jsp display the image?
> [Message sent by forum member 'henryliu' (henryliu)]
>
> http://forums.java.net/jive/thread.jspa?messageID=359278
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
> For additional commands, e-mail: users-help@glassfish.dev.java.net
>

_________________________________________________________________
Get your vacation photos on your phone!
http://windowsliveformobile.com/en-us/photos/default.aspx?&OCID=0809TL-HM
[att1.html]

Hassan Schroeder

On Wed, Aug 5, 2009 at 1:04 PM, wrote:

> I coded a form-based login jsp and it works fine and allow me to login (I already did all setups). However the login jsp cannot display the image which I put in the jsp.

>  

Do you have other images in that directory? Can you see them? If
so, view source to see what their url path is.

And is your app the root (/) context? If not, that url isn't going to work
for sure.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

henryliu
Offline
Joined: 2009-08-05

Yes, there are other images in that directory /images.

The home page jsp which is forwarded by successful login page can display the same image.

Just the very first login jsp page can not display the image.

What do you mean "And is your app the root (/) context? If not, that url isn't going to work for sure."?

Thanks,

Hassan Schroeder

On Wed, Aug 5, 2009 at 1:35 PM, wrote:

> The home page jsp which is forwarded by successful login page can display the same image.

So what's the path when the image is successfully displayed?

> What do you mean "And is your app the root (/) context? If not, that url isn't going to work for sure."?

If your app context is, e.g., /example, you would have to set the img
src as /example/images/foo.gif. Or use relative paths, or (better) do
url encoding of all your links via the JSTL standard lib.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net

henryliu
Offline
Joined: 2009-08-05

Hi, Hassan:

Thank you very much.

The file structure is like this:

AISWeb/WebContent/jsp/homePage.jsp

AISWeb/WebContent/templates/header.jsp
AISWeb/WebContent/templates/layoutMain.jsp

--------------------------------
layoutMain.jsp:






-->

------------------------------
header.jsp:

------------------------------------

But the login jsp is not coded as same as the home jsp:
AISWeb/WebContent/login.jsp

Hassan Schroeder

On Wed, Aug 5, 2009 at 2:14 PM, wrote:

> The file structure is like this:

I really don't care about the file structure.

Do `view source` *in a browser* of the page that works and the one
that doesn't. Compare the image src URLs and that will tell you what
you should be doing.

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: users-help@glassfish.dev.java.net