reset password
Author Message
abajpai
Posts: 52
Posted 15:18 Apr 09, 2011 |

I'm trying to geth the default questions page to load on start up automatically. But it's not working. The annotation on the servlet is as follows: @WebServlet(urlPatterns = "/DisplayQuestions", loadOnStartup = 1). When I try to go to "http://localhost:8080/CS320Answers/' I get a 404. But if i go to 'http://localhost:8080/CS320Answers/DisplayQuestions' I get the page. Not sure what's wrong here.

cysun
Posts: 2935
Posted 15:26 Apr 09, 2011 |

If you want to access the servlet at the URL http://localhost:8080/CS320Answers/, you need to map the servlet to "/" (i.e. the root path of the application), so the annotation should be

@WebServlet( urlPatterns = "/", loadOnStartup = 1 )

If you want to access the servlet at both URLs, the annotation should be

@WebServlet( urlPatterns = {"/", "/DisplayQuestions"}, loadOnStartup = 1 )

abajpai
Posts: 52
Posted 15:48 Apr 09, 2011 |

Thank you professor.

Last edited by abajpai at 15:48 Apr 09, 2011.