File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet Invocation problem through Hyperlinks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Invocation problem through Hyperlinks" Watch "Servlet Invocation problem through Hyperlinks" New topic
Author

Servlet Invocation problem through Hyperlinks

abhinav singhal
Greenhorn

Joined: Jun 19, 2003
Posts: 29
Hi,

I have developed a very simple application.The problem I am facing is calling servlet through an HTML's hyperlink.

I have given the code as:

<a Href="http://localhost:7001/Forum/Servlet" >Servlet</a>

in the HTML

Here the "Forum" is a folder which has WEB-INF and within WEB-INF Class called Servlet is kept.

So now as I am using weblogic I am unable to direct the servlet request directly to the "Servlet" class. Actually, I am avoiding invocation of class through the DD.And, I want to get the "servlet" invoked when the user clicks on the hyperlink

Please let me know what may be the problem.

Regards,
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

it needs to be {YOUR_APP}/WEB-INF/classes/{YOUR_PACKAGE}/{YOUR_SERVLET_CLASS}

You then need to map your servlet in your deployment descriptor (web.xml).

Here is a deployment descriptor for a simple hello, world type servlet


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
abhinav singhal
Greenhorn

Joined: Jun 19, 2003
Posts: 29
Hi,

Do you mean that in the hyperlink itself I have to give

"http://localhost:7001/Forum/WEB-INF/Classes/Servlet"

1) Does the hyperlink send the request to server or it just acts as a simple link?

Regards,
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12678
    
    5
No, he means what he said - your web.xml has to define the servlet and the url that will connect to it. Your link must use the url defined in web.xml - see the servlet mapping entry in the example.

1) Does the hyperlink send the request to server or it just acts as a simple link?

ALL links cause a separate GET request.
Bill
[ August 22, 2005: Message edited by: William Brogden ]

Java Resources at www.wbrogden.com
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by abhinav singhal:
Hi,

Do you mean that in the hyperlink itself I have to give

"http://localhost:7001/Forum/WEB-INF/Classes/Servlet"

1) Does the hyperlink send the request to server or it just acts as a simple link?

Regards,


Assuming the contextPath (application name) is "MyApp", the url would be.
Also assuming an "out of the box" Tomcat installation..

http://localhost:8080/MyApp/simple-servlet
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Invocation problem through Hyperlinks
 
Similar Threads
Multiple Modules - Help?
HTTP 404 Not Found Error
Problem running a struts 1.1 tutorial
http status 404 The requested resource is not available.
calling servlet