This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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!