2

I am trying to test the following servlet code using httpunit servlet runner. Here every thing goes fine except jsp pages which includes jstl.

public class ListTenantServlet extends HttpServlet {

  private static final long serialVersionUID = 1L;
  private static final Logger log = Logger.getLogger(ListTenantServlet.class.getName());

  public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,
      IOException {

    doProcess(req, res);
  }

  public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,
      IOException {

    doProcess(req, res);
  }

  private void doProcess(HttpServletRequest req, HttpServletResponse res) throws ServletException,
      IOException {
       CompanyStatus companyStatus = TenantStatus.Paid;
       req.setAttribute("companyStatus" companyStatus);
       RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/tenantList.jsp");
       dispatcher.forward(req, res);
  }

If i try to test the above code it is giving the following exception but the servlet is working fine in the local server.

Error on HTTP request: 500 org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application [http://localhost/contextParam/tenantmgr/listTenant]

Note: My ListTenant.jsp is having jstl code, the test works fine if i remove the jstl code.

Please help me to make it work.

majji
  • 169
  • 2
  • 3
  • 19

1 Answers1

0

A bit late, but, you need to put some jars available to servlet unit. At the first it hasn't most of then. A nice solution it's just copy the same jars from your local server, ex. if you are using tomcat the TOMCAT_HOME/lib/*.jar.

I have automating JSP testing with ServletUnit+Spring+Maven and add some dependencies look my answer here

Community
  • 1
  • 1
kszosze
  • 341
  • 4
  • 9