Reputation: 1359
I have to call function based on the request.getParameter("name")
value. If I use the following code I am getting error:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 82 in the jsp file: alert.jsp
url cannot be resolved to a type
This is the code I used:
if(request.getParameter("name")==null)
{
test=0;
out.println("user:"+user);
String url[][]=mon.fun(user);
}
else{
test=1; out.println("ser:"+ServerName+" "+user);
String url[][]=mon.function(ServerName,user);
}
for(int i=0;url!=null&&i<url.length;i++){
out.println(url[i][0]);
}
But if i call those functions separately that is not inside the if condition, I am able to access the url values.
Where am I going wrong?
Upvotes: 1
Views: 2515
Reputation: 206679
Put
String[][] url;
before your if
clause, and set its value inside the blocks with:
url = ...;
Variable go out of scope as soon as the block it's declared in is closed.
Upvotes: 4