aspose file tools*
The moose likes Servlets and the fly likes Cannot Invoke Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cannot Invoke Servlets" Watch "Cannot Invoke Servlets" New topic
Author

Cannot Invoke Servlets

Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
I was working on a Web App project in NetBeans and I decided to move the location of my JSPs. I moved each JSP and remapped all of the links, however, it cannot invoke servlets even though the web.xml is correctly configured.

Is this a bug in Netbeans? I've tried changing web servers from tomcat to glassfish and same result.

I've attached the code for my servlet, the web.xml and link in jsp page. Basically, I'm trying to simply forward the user to another jsp page through a servlet. Please let me know any ideas or suggestions. Thanks, in advance.








Here is the link I'm using in my JSP to invoke the NewPoam servlet:
<a href='NewPoam'>New POAM</a>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

You need a servlet mapping, and your URL should start with the context path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ron Ingram
Ranch Hand

Joined: Mar 11, 2011
Posts: 63
Thanks for the response. I thought anytime I create a servlet mapping in the web.xml file, I no longer need to add the context path, just simply name the servlet to match what is in the web.xml. Guess I was wrong as a newbie...

I added the 'context path/Servlet-name' and it works.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61415
    
  67

Remember that the form action is on the client. The browser has no knowledge of your mappings, so you must use the context path.
 
Consider Paul's rocket mass heater.
 
subject: Cannot Invoke Servlets