Questions of Test: Servlets and JSP Interview questions

More >>


What is the result of adding following header?


Which of the following  statements are true about GET and POST methods?


Given following form:
<form action="">
  <input type="text" name="Name">
  <input type="submit" value="Save"> 

and a servlet code:
public class RegisterServlet extends HttpServlet{
  pulic void doPost(HttpServletRequest req, HttpServletResponse res) {
  // registration logic goes here

With the above code, assuming the servlet is configured properly and registration logic works good, trying to register user fails. 
Choose one reason.


Which of the following statements are true about setHeader() and addHeader() methods?


Which HTTP method is used by the client to check what server receives when request is made?


What is the result of following code, given there already exists a header by name "TestHeader".

response.addHeader("TestHeader","TEST VALUE");


Which HTTP method is non - idempotent?


Given a servlet 
public class myServlet extends HttpServlet{
  int allowable_connections;
  public myServlet(){
    allowable_connections = getServletConfig().getInitParameter("allowable_connections");

   public void service(HttpServletRequest req, HttpServletResponse resp) throws Exception{
  PrintWriter out = request.getWriter();
  out.println("Allowable connections are:"+allowable_connections);

Given allowable_connections  init parameter's value is  defined as 10 in the web.xml for the servlet,
what will happen when a POST request is received for this servlet?


I have a init parameter in my web app for remote server name which I connect to in a servlet named ConnectionServlet.The ConnectionServlet reads this parameter in its service() method. Recently I changed my settings and shifted all data to another server by different name and ip. What are minimal things I have to do to make this change take effect?


My application is throwing various exceptions and I have to redirect to error page when there is some Exception. What are my possible options?

More >>