Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

_jspService methiod calarification

 
vineet walia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code Source is scwcd study guide



why this out object is not available in _jspService. it is showing cnt resolve

 
Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper
Pie
Posts: 2408
93
Android Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vineet,

You can override the jspInit() and jspDestroy() methods in a jsp, but you can't override the _jspService() method.

JSP.11.1.1.1 Protocol Seen by the JSP Page Author
....
In JSP 2.0 this is done by defining methods with the names jspInit and jspDestroy in a
declaration scripting element in the JSP page. The jspInit method, if present, will
be called to prepare the page before the first request is delivered. Similarly a JSP
container can reclaim resources used by a JSP page when a request is not being
serviced by the JSP page by invoking its jspDestroy method, if present.
A JSP page author may not (re)define servlet methods through a declaration
scripting element.

Regards,
Frits
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vineet walia wrote:
why this out object is not available in _jspService. it is showing cnt resolve


How do you know that, the problem with out implicit object?
 
vineet walia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
eclipse is showing that error ....
for me it is showing only... cnt resolve this object
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vineet walia wrote:eclipse is showing that error ....
for me it is showing only... cnt resolve this object


As Frits indicated, you can't override _jspService() method.
 
vineet walia
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes i go it
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vineet walia wrote:yes i go it

So, is it the problem? Let's know it! Thanks!
 
Darryl Smith
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not be overriding the _jspService method - The real problem.

Your problem is out is not declared. Why that happens is that when the JSP page is translated the JSP translator creates a _jspService method and then it starts initializing some of the implicit objects. One of the objects it instantiates is out.

Here is a snippet from the java file created by Tomcat 5.5



Have a look at line 10 and 22.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl Smith is right! all the implicit objects are available with in service method of jsp. in other word, you can use implicit object only with <% %> and <%= %>.
and it is not possible with declaration(<%! %>)

As a side note: these scriptlets are obsolete.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic