What are the ways to write comments in the JSP page? Give example.
Hidden comment
Show comment
HTML Comments - The Container passes these comments straight on to the client, where the browser interprets them as HTML comments. The commented out blocks still display in the source code. JSP Comme...
What JSP lifecycle methods can I override?
You cannot override the _jspservice() method within a JSP page. You can however, override the JSPinit() and JSPdestroy() methods within a JSP page. JSPinit() can be useful for allocating resources like database connections, network connections, and so forth for the JSP page. It is good programming practice...
What is the difference between relative and absolute url?
absolute url is full url relative url is part of url wn we are in app
As there seems to still be confusion about the difference between relative and absolute urls, I thought I'd post a little information and a reference link for everyone. An url that is ABSOLUTE shows ...
How to disable the expression language in a JSP?
isELIgnored="true"
We can use isEliIgnored property or we can disable by using below code..
How will you handle the exception without sending to error page? How will you set a message detail to the exception object?
isErrorPage and errorPage
Example:
The exception will be thrown inside the catch:
<% int x = 5/0;%>
The exception is : ${catchException}
There is an exception: ${catchException.message}
How do you call stored procedures from JSP
we can do same as doing in java wd scriptlet
We can call stored producedure using sql tags in jstl "java5 For example, calling a stored procedure that returns a result set: exec ExampleProcLoadExample ? ...
How to transfer data over multiple pages?
we can set attribute in application session or request attribute.here page wont be use ful bcz scope of page is same page only
1.page
2.session
3.request.
4.application
using these scoped variables we can translate data from one resource to another
ex: request.setAttribute("key","value");
Object o=getAttribute("key");
Pass control from one JSP page to another
Write sample code to pass control from one JSP page to another?
The RequestDispatcher objects forward method to pass the control. The response.sendRedirect method
Code
<% response.sendRedirect("RedirectIfSuccessful.html"); %> <% if(st==""){ getServletContext().getRequestDispatcher("/form.jsp").forward(request, response); } else{ getServletContext().getRequestDispatcher("/welcome.jsp").forward(request, response); } %>
There are 2 ways to redirect the page
1) Use the forward :- By using this
you will get the all the objects in the redirected page.
2) response.sendRedirect("Path") :- In This case the control is not transferred to the next page.
What is need of JSP implicit objects?
application javax.servlet.ServletContext config javax.servlet.ServletConfig exception java.lang.Throwable out javax.servlet.jsp.JspWriter page java.lang.Object PageContext javax.servlet.jsp.PageContex...
Why we need web container to deploy the servlet or JSP ?
I.E why we can not run the application like simple Java program
The web container is a Java runtime environment which is responsible for managing life cycle of JSP pages and Servlets. A web container is responsible for instantiating, initializing and invoking Serv...
Containers are like window for Servlet and JSP's to ourside world. As explain by many answers it provides interface to ourside world. Few advantage of deploying JSP and servlet in container is:1) ...
When and why jasperexception occurs?
What exactly mean by the following:
jsp-api.jar is missing in the build path.
What happen if it is occurred in Struts 2.1.0 ? while i trying to submit a list value from JSP page in action class : -
why jasper exception occurred when action successfully got the list value - and It give " Unhandled exception in struts : JasperException.
How to write js unit test cases for creating multiple check boxes ?
Can we use main method inside JSP? Why?
Can someone tell me...how a servlet container execute init(),service() and destroy() method in a sequential manner ?
is it true that a servlet container itself contains a main() method which call these methods ?
thanks in advance...
We can use main method in Jsp/servlet, but there is no use. This main() method will not execute throughout the life cycle. Then why should we need to use.Generally these JSP/Servlets are server side t...
Share data in two different projects
How to share the data in two different projects in JSP or servlets
NO, There will be one single instance of the servlet in the web-container ,when request arrives to the server a thread will be created rather creating the object. so that multiple request will have ...
single servlet object will be loaded in memory and one thread per request would be created by the container to serve those requests.
Thanks,
Vinay
JSP is an advanced version of Java Servlets. It will also extends the functionality of a web server. It will give clear separation between application logic and prosentation logic.
Hi, JSP is a server side scripting language. It encapsulates the java code with the html code. It is simpler and easier to develop application with JSP than servlet or any othere.
no. both session retained.
Hi Prasanth, The case is differnt here.Assume you have opened gmail.com and logged in... session will be created.Then you have tried to replace the url as yahoo.com, here the browser will identify the...
In order to access the request object from a JSP page? Which step you must complete among the following:a. Call the getrequest method of the JSP page.B. Use the getservletconfig method of the JSP page, then call the getrequest method of the servletconfig object.C. There is never a good reason to access...
request is an implicit object in JSP
How do you use "synchronized" blocks?
Is there other way to prevent next thread to access the resource with out using "synchronized" blocks?
We can use thread local variable as an alternative to synchronization.
there is a way to do so, but its a bit complex and has be done by a programmer.Well u can implement the semaphore architecture using the the semaphore variable.this can be done as following:take a boo...
Jsp container provides a easy way to access standard objects and actions..
Easily saying
1)Auto compilation(translation.....)
2)Not deployment descritpor specific
3)Multiple deployment is avoided.