0

kindly gimme insight into whats going on in here, I have a deployment descriptor web.xml where url patterns are mapped to the servlet such as this

  <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>>controller.ControllerServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/category</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>>ControllerServlet</servlet-name>
    <url-pattern>/checkout</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>cart</url-pattern>
</servlet-mapping>

the resources corresponding to the url patterns are all placed inside WEB-INF/views directory, when i run any of the pages the netbeans console says the module has not been deployed, but if i remove the servlet configuration code from web.xml, it works fine, I dunno what's going on in here, and here is the servlet controller

    @WebServlet(name = "ControllerServlet",loadOnStartup=1, urlPatterns = {"/category", "/addToCart", "/viewCart","/updateCart","/checkout","/purchase","/chooseLanguage","/cart"})
public class ControllerServlet extends HttpServlet {
  @Override
protected void doGet(HttpServletRequest request,HttpServletResponse response )
        throws ServletException,IOException{
//return the part of this request's url that calls servlet
String userPath=request.getServletPath();
if(userPath.equals("/category"))
{
//TODO: implement category request
}
else if(userPath.equals("/viewCart"))
{
//implement view cart request
}
else if(userPath.equals("/checkout")){
//implement checckout
}
else if(userPath.equals("/chooseLanguage")){
//language request
}
//Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
//A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response.
//The resource can be dynamic or static.
String url="/WEB-INF/Views" + userPath + ".jsp";
try{
request.getRequestDispatcher(url).forward(request, response);
}
catch(Exception ex)
{
    ex.printStackTrace();
}
}
 @Override
protected void doPost(HttpServletRequest request,HttpServletResponse response)
        throws IOException,ServletException{
String userPath=request.getServletPath();
if(userPath.equals("/addToCart"))
{
//add to cart
}
else if(userPath.equals("/updateCart"))
{
//update cartaction
}
else if(userPath.equals("/purchase"))
{
//purchase
    userPath="/confirmation";
}
String url="/WEB-INF/Views"+userPath+".jsp";
    //Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
//A RequestDispatcher object can be used to forward a request to the resource or to include the resource in a response.
//The resource can be dynamic or static.
try{
request.getRequestDispatcher(url).forward(request, response);

}
catch(Exception ex)
{
ex.printStackTrace();
}

}

}

none of pages get run

Jawad
  • 313
  • 4
  • 16
  • You have a typo in your `web.xml` snippet above. In any case, you should update your question to show the sorts of URL requests which are hitting, and which are missing. – Tim Biegeleisen Sep 18 '16 at 09:18
  • none of the url requests is responded, the console says module has not been deployed even if i run index page that is placed outside of WEB-INF folder – Jawad Sep 18 '16 at 09:35
  • https://netbeans.org/kb/docs/javaee/ecommerce/page-views-controller.html i'm following this tutorial. – Jawad Sep 18 '16 at 09:38
  • Yes, the servlet-class section has an extra angle bracket. – Michael Akerman Sep 19 '16 at 16:37

0 Answers0