Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can any body tell how to call servlet withot using web.xml

 
vijayakumar durai
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


i am using eclipse.i have Login servlet in default package i have called servlet from login form

<form name="frmlogin" method="get" action="http://localhost:8080/servlet/Login">
my project name is OnlineCourseRegistration

it show error httpresource is not available
i called like this this also not working

<form name="frmlogin" method="get" action="http://localhost:8080/OnlineCourseRegistration/Login">

it show error http resource is not available


thanks in advance


 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a web.xml file to declare the servlet names and classes. Any decent servlet tutorial explains how to do that.
 
ujjwal soni
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You cannot execute a servlet without web.xml, configuration for servlet must be there so that the container is able to execute it.

 
vijayakumar durai
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have web.xml in my application suppose if i didn,t mention servlet name and classes in web.xml can I able to call servlet?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No.
 
ujjwal soni
Ranch Hand
Posts: 403
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why you want to do this ?
 
vijayakumar durai
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks friends just i want to know
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18152
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:No.


It's considered a security risk. If you like security risks, call Bill Gates. Java was expressly defined to minimize security issues.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably don't want to include the host/port information in the form's "action" attribute, by the way.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Back in the beginning of servlets somebody created the Invoker servlet. With the invoker active you had the appearance of servlet classes in the default package being called without a web.xml entry. This was an illusion because the invoker was really getting the request first - as configured in web.xml.

This was supposed to make it easier for newcomers to experiment with servlets without getting into web.xml but it has proved to be a disaster and caused much more confusion than web.xml ever did.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic