• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem calling Servlet from jsp.

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what I have:


JSP:

<form method ="GET" action = "TestResult.do">

<center><input type="submit"></center>
</form>


web-xml:

<servlet>
<servlet-name>testing</servlet-name>
<servlet-class>testResult.TestResult</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>testing</servlet-name>
<url-pattern>/TestResult.do</url-pattern>
</servlet-mapping>


Servlet:

package testResult;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class TestResult extends HttpServlet{


These work perfectly with JSP in the root directory. The JSP can call servlet with no problem at all. However, If JSP is placed in another directory e.g. root/anotherFolder/file.jsp, then I face the problem of calling my Servlet from the JSP.

Please if you have any answer to this question, please help. I am using Tomcat as my Container.
Waiting to hear from you.
Thank you.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try change your JSP to

<form method ="GET" action = "/TestResult.do">

<center><input type="submit"></center>
</form>

If I am right, since JSP will translate and compile into servlet. When a relative path is used, the generate JSP_servlet will use it related path to find another servlet.

In the cases, the relative path included the directory of the jsp, which doesn't fall into the context path.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic