Results 1 to 8 of 8
  1. #1
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default Implicit object in jsp declared where?

    I have one question regarding implicit objects in jsp. we can use implicit object in jsp scriptlet without declaring them. it means they are declared somewhere. i wanted to know that in which class/interface these variable declared. one more question, why we are not able to access those variables in declaration part of jsp.:o

    Regards,
    Mahendra Athneria
    Mumbai - India

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default

    implicit objects are available only in jspService method.It will not be available in declaration.Open the java file generated for the jsp and gothru for clarification
    Ramya:cool:

  3. #3
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default

    thanks Ramya for your quick reply. i got it that there scope is limited to service method only. but my question is that while we are using those variables in jsp they are pre declared, thats why we are able to use them. So where is those variable decalred? what is the location?

  4. #4
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default

    Implicit objects are getting created by the container automatically whenever it generates the servlet code for the jsp and it place the created objects in service method scope.
    Ramya:cool:

  5. #5
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default

    so u want to say that it is created by the container at the time of translation phase of jsp? if this is the scenario then my doubt is - how we can use those variable prior to the declration, because firstly we use them then it will translated and create the object?

  6. #6
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default

    what do u mean by declaration?

    This implicit object is available within <% %> Not for <%! %>.

    Whatever actions taking place within scriptlet tag is a service scope.
    Ramya:cool:

  7. #7
    Join Date
    Jan 2009
    Posts
    14
    Rep Power
    0

    Default

    declaration means first decalre the variable then use. im not talking about <%!%> scriptlet.
    simple examle-
    if i have to use a string varible str, somewhere then firstly i have to declare it. like
    String str = new String(); // declaration of str

    now i can use str variable.

    same in jsp, implicit varible declared some where. as u said it is created inside the servlet when jsp get translated to servlet. so i am asoing ki how we can use those varible in jsp if they are declared after translation phase?

    got it or not?

  8. #8
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default

    If u see the java file generated for this jsp page,U can understand better regarding the translation phase and where exactly implicit objects are created to get a clear picture.
    Ramya:cool:

Similar Threads

  1. Class is public, should be declared in a file
    By goldhouse in forum New To Java
    Replies: 7
    Last Post: 05-10-2012, 10:17 AM
  2. Implicit objects
    By JavaJunkie in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 05-20-2009, 07:21 AM
  3. JSP implicit objects
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •