This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "declaration" Watch "declaration" New topic


Anoopriya Muthuswaami

Joined: Nov 20, 2008
Posts: 25
Consider the following example
<%! String str="Hello"; %> //this becomes instance variable in generated servlet

<% String str="GoodDay"; %>//this becomes local variable in service method
<%= str %>

The result of this is GoodDay.

My question is how do I print the value 'Hello'?
Matteo Palmieri

Joined: Sep 09, 2008
Posts: 28
This should do the case:

SCJP1.4: 96% SCWCD5: 91%
Anoopriya Muthuswaami

Joined: Nov 20, 2008
Posts: 25
Thanks.. It worked.
Tuna Töre
Ranch Hand

Joined: Aug 17, 2008
Posts: 220

good question... Anoo Raj


Core Spring Certified Professional + SCJP 6.0 + SCWCD 1.5
It is sorta covered in the JavaRanch Style Guide.
subject: declaration
It's not a secret anymore!