• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jspInit() method

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Every body! I have a few doubts regarding the lifecycle methods of jsp. I request Jsp gurus to clarify them.
1 ) I have overridden jspInit() method in my jsp page. I have written this the declaration tags(<%! here %> ).My doubt is that this method should be called only once in the life cycle of the jsp page.But i had observed that this method is getting executed when ever that page is being requested( I put a System.out statement in that method). Please explain this concept.
@) This is regarding the <jsp:forward>.When i am forwarding a requst from one jsp page to another the 'request' is not the same in the second page. I am not able to read the parameters received fron the first page.Explain me this.
Thanx in advance
clkanth.
 
Desperado
Posts: 3226
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK... I'm no expert on JSPs but why are you overriding the init method of the JSP? It is improper (according to architecture model 2) to write much Java code in a JSP scriptlet and you're talking about overriding the init() method (of the generated servlet) right there on the JSP? Beats me!
On question # "@":
Is the forwarded page's scope "session" or at least "request"?
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ClKanth,
i am new to jsp, can u help me out with more on the life cycle of jsp.
thanks kanan
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Regarding your second question:
@) This is regarding the <jsp:forward>.When i am forwarding a requst from one jsp page to another the 'request' is not the same in the second page. I am not able to read the parameters received fron the first page.Explain me this.
I�m not sure whether you are expecting the parameters received by the first page to be available in the new page (they won't be), or if you have sent the parameters along from the first page to the new page using the <JSP:parm>. I haven�t had problems with this, so it all seems a bit strange. Sooooo, here�s a couple of thoughts:
When the JSP container gets the request for a transfer to a new JSP page (as opposed to the other possible types of targets), it creates a new pageContext object, but the Request object and the Session object will remain the same.
You can pass information to the new page by using the <jsp:parm name=�passingArg_1� and a value statement. The new program can get at this information by using the getParameter ( ), getParameterValues ( ), and getParameterNames ( ) methods.
<!-- Pass control to jspTest1.JSP with passing arguments -->
<html>
<body>
<jsp:forward page=�jspTest1.JSP� >
<jsp:parm name=�passingArg_1�
value=�ABC� />
<jsp:parm name=�passingArg_2
value=�XYZ� />
</body>
</html>
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic