This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes out.println( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "out.println("") is not working in between declaration tags?" Watch "out.println("") is not working in between declaration tags?" New topic
Author

out.println("") is not working in between declaration tags?

yamini nadella
Ranch Hand

Joined: Apr 13, 2004
Posts: 257
<HTML><BODY>
Hello 1 <B>
<%!
int i=10;
public void a()
{
i = i+10;
out.println("inside ");
}

%> </B>
Hello 1
<B><%
a();
out.print("first line "+i+6);
%></B>

</BODY></HTML>
---
above script is giving HTTP status 500 error at first out.println, why?
is it means in between <%! and %> can't we use implicit objects?.

In between declaration tags it is allowing to declare methods and call them self. But why it is not allowing to print.
Sumitro Palit
Ranch Hand

Joined: Dec 13, 2003
Posts: 37
You are right.
The implicit objects are declared inside the generated _jspService method.
You cannot use the implicit objects outside of the _jspservice scope (scriptlets.)

- ortimuS
 
wood burning stoves
 
subject: out.println("") is not working in between declaration tags?
 
Similar Threads
declaration section variable is not getting reset for each refresh operation?
Need to split up servlet
Servlet Invocation
difference between out.println() and System.out.println() in JSP?
question about session?