JSP Interview Questions and Answers
Ques 26. Difference between GET and POST.
Ans. In GET your entire form submission can be encapsulated in one URL, like a hyperlink. query length is limited to 255 characters, not secure, faster, quick and easy. The data is submitted as part of URL.
In POST data is submitted inside body of the HTTP request. The data is not visible on the URL and it is more secure.
Ques 27. What is a output comment?Ans. A comment that is sent to the client in the viewable page source.The JSP engine handles an output comment as uninterpreted HTML text, returning the comment in the HTML output sent to the client. You can see the comment by viewing the page source from your Web browser.
<! comment [ <%= expression %> ] >
<! This is a commnet sent to client on
<%= (new java.util.Date()).toLocaleString() %>
Ques 28. What is a Hidden Comment?Ans. A comments that documents the JSP page but is not sent to the client. The JSP engine ignores a hidden comment, and does not process any code within hidden comment tags. A hidden comment is not sent to the client, either in the displayed JSP page or the HTML page source. The hidden comment is useful when you want to hide or "comment out" part of your JSP page.
You can use any characters in the body of the comment except the closing %> combination. If you need to use %> in your comment, you can escape it by typing %\>.
<% comment %>
<%@ page %>
<head><title>A Hidden Comment </title></head>
<% This comment will not be visible to the colent in the page source %>
Ques 29. How do I include static files within a JSP page?Ans. Static resources should always be included using the JSP include directive. This way, the inclusion is performed just once during the translation phase. Do note that you should always supply a relative URL for the file attribute. Although you can also include static resources using the action, this is not advisable as the inclusion is then performed for each and every request.
Ques 30. What are the two kinds of comments in JSP and whats the difference between them.Ans. <% JSP Comment %>
<! HTML Comment >
Most helpful rated by users: