wood burning stoves 2.0*
The moose likes JSP and the fly likes this don't make sense jsp variable declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "this don Watch "this don New topic
Author

this don't make sense jsp variable declaration

Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
my.jsp code below
the problem is if I pass the smyDir into the test() method it works. I don't understand if it is global why is it undefined inside my function.
<%@ page language="java" %>
<% String smyDir = request.getRequestURI().substring(0,(request.getRequestURI().indexOf("/",1))); %>
<%!
public void test(int iWidth, JspWriter out)
{
try{
out.print("<img src=\"" + smyDir + "/images/rans.gif\" width=\"\"" + iWidth + " height=\"1\">");
}catch(IOException e14)
{
System.out.println("IOException at Spacer");
}

}
%>
thanks Ray


SCJO, SCJD, SCWCD, I-Net+, A+, Network+, MCSD, MCDBA, MCP, MCT
Roy Ben Ami
Ranch Hand

Joined: Jan 13, 2002
Posts: 732
its not global (or more correctly instance variable) .
when u defne somthn between the <%! %> it is an instance variable (like the function u defined).
anything between the <% %> is actually being done inside the service method of the jsp servlet!
Ray Smilgius
Ranch Hand

Joined: Jan 29, 2001
Posts: 120
Thank you this makes alot more sense.
 
Consider Paul's rocket mass heater.
 
subject: this don't make sense jsp variable declaration