How can I use the results of my method?
ea:
<%!
method (int x) {
stuff
return y;
}
%>
<%
out.println(y);
%>
how can I make this work? "y" is a variable made during the
method.
Answer / Yadvendra Kumar Singh
To access and display the value of `y` from your JSP method, you need to declare it as a request attribute before returning it in the method. Here's how you can modify your code:
```java
<%!
public void method(int x) {
request.setAttribute("y", stuff); // assign the value of y to the request object
y = returnValue; // use the value of y in your calculation or operation
}
%>
<% method(someValue); %> <!-- call the method with some value -->
<% out.println(request.getAttribute("y")); %> <!-- print the value of y -->
| Is This Answer Correct ? | 0 Yes | 0 No |
What are the standard actions available in jsp?
What is Include directive?
What is the <jsp:param> standard action?
which is the place to learn java in chennai..
How to deactivate el on jsp?
How are custom tags in jsp created?
What are actions and directives in jsp?
Can init method be overridden?
Explain the <jsp:param> action?
Can you use javascript in jsp?
What is context in web application?
Is jsp technology extensible?