JSPs and Servlets Tutorial 14 - Using jspInit and InitParams

preview_player
Показать описание
Here we'll see how our understanding of the init concepts of servlets translates to JSPs.
Рекомендации по теме
Комментарии
Автор

For those who also got confused with jspInit() and _jspInit() methods. A JSP-servlet extends abstract class HttpJspBase which is an HttpServlet. In HttpJspBase:

public final void init(ServletConfig config) throws ServletException {
    super.init(config);
    jspInit();
    _jspInit();
}

the underscored method is redefined by Tomcat while creating a servlet and the other method stays empty in order to let the user redefine it.

Ruzveld
Автор

Dude these videos are awesome! Thank you so much for doing this. I have learned more from these videos than anything else.

sparkman
Автор

Thanks for the sharing the tutorial they are helping in knowing the starting blocks for JSP!!

ankitjain
Автор

Thanks for the tutorial, I have one question. You are overriding the init() method in JSP file(generated code). But i noticed in Parent class method signatures, its name starts with _(underscore), but in your overridden method, underscore is not there. Did you miss that or it is the way it should be, then in that case, it cannot be overriding. Please  correct me if i am wrong

suriuonutube
Автор

You made my Thanksgiving long weekend :-)

LivelovelaughEveryday
Автор

Hello Koushik, just wanted to brace you for this wonderful tutorial, you great lecture and it was not just increase my knowledge it also very fun engaged to watch all of your other tutorial ... well done I wish you will deliver more great tutorials in future .


Thank and great regards,
Zohar N

hbjlwrh
Автор

thanks for this explanation, but i have a question, when i do "super." to see the method that i m overriding this method don't appear in the eclipse list. I think that this happens because ecplise don't recognize this jsp like a HttpJspPage but like a Servlet. M.i wrong?

bruno
Автор

Java Brains earlier when we used servlets you showed us how we can use init params using both (<init-param> in web.xml and @WebInitParam annotations in servlet itself) but in JSP there's no alternative to use the Annotation method(right?). So the conclusion : while using JSP and desiring for init params you are forced to use web.xml <init-param>

thevagabondyt
Автор

In place of TOMCAT, I am using Glassfish, I found the java file for the init JSP file, but didn't find the jspInit() and destroy method in there, not sure why...anyone has any clue?

AkashSingh-elew
Автор

At your command line prompt try: find -mtime 0 | fgrep _jsp.java > /home/dir.txt
That should create a text file with the path to *_jsp.java. Mine was deep inside the hidden folder .metadata.

EurekaYoga
Автор

<servlet>


<init-param>
<param-name>test</param-name>
<param-value>me</param-value>
</init-param>
</servlet>

<servlet-mapping>


</servlet-mapping>


Then in my init.jsp I can get the init params using

However, I am using WebSevlet 3.0 annotations and I can't see equivalent jsp-file annotation. I am looking for something along these lines

where I can use jsp-file annotation. So I need to set the jsp init params without using web.xml.

kaushiksinha
Автор

does your jsp-file tag match the spelling and case of your filename?

sparkman
Автор

You are using ServletContext in JspInit method.... can we use application object to set the value...when i check in my own editor by giving application .setAttribute in place odf servletContext it is showing error. i dont know why....
i am having doubt with implicit objects...can we use implicit objects in the Jspinit method or any in anyother method. plz help me

tejaaravind
Автор

sir i am getting null value, i dont understand how to rectify the same.. Please help me

rashikashreshtha
Автор

Why does the default username show up even if I give the username in the URL.... strange 

ManpreetSingh-qewn
Автор

The default user from the servlet config is: defined in initpage.jsp is returning null for me. Any idea why wat might have went wrong in my code as i have configured exactly as the one done in tutorial?

hussainv
Автор

If you can't find the generated servlet files, go to stackoverflow (.) com and search for question: 4543868

echelecopao
Автор

voice is not so clear....please record the voice clearly

agastyapatashalaand
visit shbcf.ru