• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing a jsp through a servlet problem

 
Matt Fry
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy all. I got this nitpick back a few days ago:

Rather than going directly to the jsp, you should make all your access to jsp pages pass through the servlet. Your URL should look something like this:

/videos/servlet/VideoServlet?action=addvideo


OK. I've tried this and can't get it to work. Perhaps because I don't fully understand what it's doing, maybe (I don't remember reading much about it in Head First Servlets & JSP). But anyway, all it does when I write the URL like that is to reload the listvideos.jsp page (which is where this link is written). I can't seem to get it to load the addvideo.jsp page no matter how I write the URL (I've tried .../VideoServlet?action=addvideo.jsp, .../VideoServlet?action=addvideo, .../VideoServlet?forward=addvideo.jsp, etc.).

Any suggestions, help, advise, etc would be greatly appreciated. Thanks!
 
Marilyn de Queiroz
Sheriff
Posts: 9059
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have an "action" in your servlet that matches the "action" in the url? Otherwise, the servlet will do the "default" action.
 
Matt Fry
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Man, that was a tough one (for me anyways). Had to dig a little bit but learned several things I didn't know and had just taken for granted. Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic