| Java FAQ | ||
| JSP FAQ | ||
| Servlet FAQ | ||
|
Advertisement
|
Why are the implicit objects not available in declarative part of JSP?Why are the implicit objects not available in declarative part of JSP? For example, following JSP code will fail to compile successfully:
...
<%! String name=request.getParameter("name"); %>
Name of person is <%=name %>
...
JSP pages are translated into servlets and then they are compiled before they can be viewed. Declaring a variable in a JSP page means that the variable will become a (non static) class attribute in the corresponding servlet. At the time when the servlet is compiled, there is no such thing as a request because a request can't come in until after the servlet is compiled and made available by the container.
In other words, |