Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP Implicit Objects

Reply
Thread Tools

JSP Implicit Objects

 
 
marcwentink@hotmail.com
Guest
Posts: n/a
 
      07-25-2006
I am reading something about JSP Implicit Objects, objectslike for
example:

request, response, pageContext, application, out, session

But then my tekst book says:

---------------------------------------------------------------------------------
Note that these implicit objects are only visible within the system
generated
_jspService() method. They are not visible within methods you define
yourself in
declarations.
-------------------------------------------------------------------------------

Ok, then this means I cannot use them? If so why mention them anyway?
Can you use them somehow?

Marcus Wentink

 
Reply With Quote
 
 
 
 
relipse@gmail.com
Guest
Posts: n/a
 
      07-25-2006
it is easy to use them, you don't have to write methods in a JSP file
for example
<%

if ( "true".equals(request.getParameter("largetext" )))
out.println("<font size=7>LARGE TEXT</font>");


%>

one thing I did when I wrote a method was to pass in the request as a
parameter...
for example...

<%!

public boolean isLargeText(HttpServletRequest request)
{
return "true".equals(request.getParameter("largetext" ));
}

%>

then you can write this code below where you need it

<%

if ( isLargeText(request) )
out.println("<font size=7>LARGE TEXT</font>");

%>


hope this helps

-ReLipse
Xhirl Software Design
www.xhirl.com/software

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I am reading something about JSP Implicit Objects, objectslike for
> example:
>
> request, response, pageContext, application, out, session
>
> But then my tekst book says:
>
> ---------------------------------------------------------------------------------
> Note that these implicit objects are only visible within the system
> generated
> _jspService() method. They are not visible within methods you define
> yourself in
> declarations.
> -------------------------------------------------------------------------------
>
> Ok, then this means I cannot use them? If so why mention them anyway?
> Can you use them somehow?
>
> Marcus Wentink


 
Reply With Quote
 
 
 
 
marcwentink@hotmail.com
Guest
Posts: n/a
 
      07-25-2006

(E-Mail Removed) schreef:

> one thing I did when I wrote a method was to pass in the request as a
> parameter... for example...


Ok so the text in the book tries to explain that if you use it in a
function you defined, the object is not there, unless you have passed
it as a parameter.....since in this defined function you are in another
scope.

In 'normal' java code snippets in JSP files on the other hand, they are
available.

Bad bad book!

Thanks a lot!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
[JSP] difference between jsp:forward and jsp:include alexjaquet@gmail.com Java 0 06-02-2006 01:21 PM
Passing implicit (standard) "config" object from jsp to java class (not servlet) cvelusc Java 5 06-03-2004 04:14 PM
Custom tags and <jsp:plugin> / <jsp:param> Raymond DeCampo Java 0 02-18-2004 01:29 AM
[JSP] Strings Constants from JSP using Struts tags Matthias Nietz Java 1 11-12-2003 04:32 PM



Advertisments