servlets interview questions

Set 25 – Servlets, JSP, JSTL Interview Questions

1. Choose all the right options that are true about the following servlet. a) web.xml entry snippet for DemoServlet xxxxx DemoServlet trafficfine 3500 b) Servlet code import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; public class DemoServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String …

Set 25 – Servlets, JSP, JSTL Interview Questions Read More »

Set 24 – Servlets, JSP, JSTL Interview Questions

1. What is the userName value printed if the html input field “user” does not exist. Choose the right option. import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class Demo extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); String userName = request.getParameter(“user”); out.println(userName); } } 1. null …

Set 24 – Servlets, JSP, JSTL Interview Questions Read More »

Set 23 – Servlets, JSP, JSTL Interview Questions

1. Choose all the right options that are valid URL mappings in web.xml file for the following servlet. public class Servlet1 extends GenericServlet { // business logic goes here } 1. <servlet> <servlet-name>Servlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet1</servlet-name> <url-pattern>/Servlet1/*</url-pattern> </servlet-mapping> 2. <servlet> <servlet-name>Servlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>Servlet1</servlet-name> <url-pattern>/myServlet1/*</url-pattern> </servlet-mapping> 3. <servlet> <servlet-name>myServlet1</servlet-name> <servlet-class>Servlet1</servlet-class> </servlet> <servlet-mapping> <servlet-name>myServlet1</servlet-name> …

Set 23 – Servlets, JSP, JSTL Interview Questions Read More »

Set 22 – Servlets, JSP, JSTL Interview Questions

1. a) Read the following servlet import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class DemoServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType(“text/html”); response.getWriter().println(“Hello Servlet”); } } What could be right URL mapping in web.xml for the above servlet. Choose the right option. 1. <servlet-mapping> <servlet-name>ds</servlet-name> <url-pattern>/myDemoServlet/*</url-pattern> </servlet-mapping> 2. …

Set 22 – Servlets, JSP, JSTL Interview Questions Read More »

Set 21 – Servlets, JSP, JSTL Interview Questions

1. Choose the right option to fill the blanks to get the values entered by the client as per the following URL. a) URL when client clicks the submit button http://localhost:8080/DemoServlet?t1=Lux&t2=5 b) Servlet snippet import javax.servlet.*; import javax.servlet.http.*; import java.io.*; public class DemoServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException …

Set 21 – Servlets, JSP, JSTL Interview Questions Read More »