Servlets Interview Questions and Answers
Ques 6. Given the request path below, which are context path, servlet path and path info?
Ans. /bookstore/education/index.html
context path: /bookstore
servlet path: /education
path info: /index.html
Is it helpful?
Add Comment
View Comments
Ques 7. What is filter? Can filter be used as request or response?
Ans. A filter is a reusable piece of code that can transform the content of HTTP requests,responses, and header information. Filters do not generally create a response or respond to a request as servlets do, rather they modify or adapt the requests for a resource, and modify or adapt responses from a resource.
Is it helpful?
Add Comment
View Comments
Ques 8. When using servlets to build the HTML, you build a DOCTYPE line, why do you do that?
Ans.
Is it helpful?
Add Comment
View Comments
Ques 9. What is new in ServletRequest interface ? (Servlet 2.4)
Ans. The following methods have been added to ServletRequest 2.4 version:public int getRemotePort()
public java.lang.String getLocalName()
public java.lang.String getLocalAddr()
public int getLocalPort()
Is it helpful?
Add Comment
View Comments
Ques 10. Request parameter How to find whether a parameter exists in the request object?
Ans. 1.boolean hasFoo = !(request.getParameter("foo") == null || request.getParameter("foo").equals(""));2. boolean hasParameter = request.getParameterMap().contains(theParameter);
(which works in Servlet 2.3+)
Is it helpful?
Add Comment
View Comments
Most helpful rated by users: