Struts <html:img> question
I posted this topic in the New to Java forum but thought I would have more luck here.
I'm using struts and would like to get the name of an image file from a session attribute i.e. -
ActionClass
session.setAttribute("image", imageName);
JSP
<html:img src="../images/<%=(String) someAttributeImageName%>.gif"><html:img>
My questions are:
1. If I declare the session attribute in the action class, how do I access it in the html:img src attribute?
2. What other html:img tag attributes do I need to use?
3. Is there a better way to do this?
Thanks for the help, I'm still rather new at this technology and have a lot to learn!
bfrmbama
[778 byte] By [
bfrmbama] at [2007-9-30 21:56:27]

In the Action Class u set the attribute imageName right!
First way
every JSP page has a request object. And so do this in ur jsp
<%
HttpSession session = request.getSession();
String imgSrc = "../images/"+(String)session.getAttribute("imageName ");
%>
<html:img src="<%= imgSrc %>"/>
Second way -
If u have a formBean or in fact any bean that holds the info about this form then u could easily set the attribute imageName on that form. Since the form is always in the request, when u return to a jsp, u can refer to the imageName through that form's accessor method. U do not have to get the handle to a HttpSession in this case. Ofcourse all of this will be possible with struts..
s