File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes JSP Declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP Declaration" Watch "JSP Declaration" New topic

JSP Declaration

Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Hi, I was wondering if methods can be decalred in JSP declarations like class variables. If so, how is it done?
<%!String toString(){
StringBuffer temp = new StringBuffer();
for(int i=0; i<10; i++){
return temp.toString();

Joined: Apr 23, 2001
Posts: 6
Yes you can do that!! this Declaration block <%! %> will added to the outside of the _jspService() method. Other Scriplet block <% %> will added to the inside the _jspService() method.
I agree. Here's the link:
subject: JSP Declaration
It's not a secret anymore!