• 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

Servlet Invocation problem through Hyperlinks

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
abhinav singhal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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,
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic