Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

How to call a servlet from a browser

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everybody,
I hope all of you understand my poor english; after solving many problems by reading this forum, i've just signed up, and this is my first question

I'd like to know how to call a servlet by using a URL.
Now i'm able to call the servlet this way beacuse i set my web.xml this way

Is there a way to call my servlet by using its name, for instance http://localhost:8080/servlet/provaservlet/ServletName?

I set the <url-pattern> element with everythings come to me, but i didn't get my goal yet!
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

Welcome to coderanch.

use following code may it solves



you can give url in url pattern then it matches respective servlet using web.xml. It is basic thing about servlets.


 
Greenhorn
Posts: 13
Android Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here ServletName is nothing but the URL-pattern, which you have defined in web.xml of application. Container internally calls the Servlet which is mapped to URL-pattern. You need go through some J2EE tutorial, best book would be Head first servlets and Jsp.

http://localhost:8080/servlet/provaservlet/ServletName
 
matteo depasquali
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, now it works.
The correct url is http://localhost:8080/projectFolder/url-pattern and not http://localhost:8080/servlet/projectFolder/url-pattern

Reading guides and articles i often saw the folder called "servlet", and i thought it was necessary to tell tomcat that i was calling a servlet.

Actually, in the example i read on the internet, the folder called "servlet", was the name of the web project:D
 
Sheriff
Posts: 67592
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is why it's important to use good names. "servlet" as the name of a web app is very poor and confusing, as you have discovered.
 
What's a year in metric? Do you know this metric stuff tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic