RE: What is the different between _jspInit() and jspIn...
when a JSP page transalated into a Servlet then jspInit() method is converted to _jspInit(). We can override _jspInit() and _jspDestry() but we can't override _jspService() method.
RE: What is the different between _jspInit() and jspIn...
when a JSP page transalated into a Servlet then jspInit() method is converted to _jspInit(). We can override _jspInit() and _jspDestry() but we can't override _jspService() method.
RE: What is the different between _jspInit() and jspInit()?
I dont know the difference between _jspinit() and jspInit() but jspInit() is not converted as _jspInit()... I have checked in the genereated java file it is the same jspInit() name I observed....
RE: What is the different between _jspInit() and jspInit()?
All those who say 'There is no_jspinit() in generated servlet'.... are wrong....
As of servlets spec 2.4, this method is generated by the container if any custom tags are used in the JSP. Otherwise it doesn't.
We can override jspInit()... in that case both th methods will be there, but that will not exactly be an override as _jspInit() will take precedence and be used for initialization.
if we try to override _jspInit() and using custom tags, container will throw compilation error saying -duplicate methods. (there will be two _jspInit() methods with same signature)
Similarly we can mention our own jspSerivce() method, but that will be of no use (even though in translated java file it will be there).
The difference between overriding jspInit() and jspService() is that - _jspService() will always be there in any JSP->java file and will take precedence and our jspService() method will not be used ever. But _jspInit() method appears in jsp->java file conditionally. so, our jspInit() method will be invoked when there is no _jspInit() method and this is quite possible.
Example:- Here is the jsp file code I tested... (I'm not putting the java file code as it is lengthy... but the jsp got translated and compiled without any error and our jspService() method was not used).
<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/TR/REC-html40/strict.dtd"> <%@ page session="false" %> <%@ taglib uri="/WEB-INF/c.tld" prefix="c" %> <c:set var="drm" value="ddd" /> <%! public void jspInit() { }
/* --duplicate method error public void _jspInit() { }*/
public void jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspWriter out = JspFactory.getDefaultFactory().getPageContext(this, request, response, null, false, 8192, true).getOut();
out.write("<!doctype html public "-//w3c//dtd html 4.0 transitional//en" "http://www.w3.org/TR/REC-html40/strict.dtd">rn"); out.write("rn"); out.write("rn"); out.write('r'); out.write('n'); out.write("rn"); out.write("sss"); } %> ddd
RE: What is the different between _jspInit() and jspInit()?
In JSP we have a life cycle methods like jspInit(), and jspDestroy() and _ JspService() methods but there is no sense if u write in ur jsp as _jspInint(), but u can write