• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Help me please

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written two servlets namely IndexServlet and LoginServlet.
Their code is as follows:

IndexServlet


Login Servlet




Can anybody tell me where I have gone wrong?
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, the first major thing I see wrong is that you are spitting out HTML in your servlet when you should just use a JSP.

Other than that, you'll have to provide more information like what it isn't doing that you think it should or error messages, stack traces, etc.
 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. your opening form tag.

2. you need web.xml also when you are working with servlet.
 
Ram Kas
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Greg,

Here, the IndexServlet should execute LoginServlet but it is not happening even though both of them are in same directory

Dinakar.K
 
Ram Kas
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks rathji
 
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
Dinakar Kasturi,
Welcome to JavaRanch!

In an effort to help you get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see: UseAMeaningfulSubjectLine

"Help me please" tells us nothing about the nature of your question.

Again, welcome to JavaRanch and good luck with your question.
-Ben
[ August 02, 2006: Message edited by: Ben Souther ]
 
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be you would have checked this, but I dont see any link or forwarding to the other servlet from IndexServlet. One thing is you can include that in the action tag in the form.

Tell us exactly what error message you get.
 
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

out.println("</form action = 'LoginServlet' method = 'GET' >");


What is the servlet-mapping for your LoginServlet. You just can't reference your servlet by using the servlet name. You need to use the servlet-mapping.

Post your web.xml
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't worry Here is the code for IndexServlet



and here is the code for LoginServlet




Add the following snippet to your web applications web.xml:



Try this and your browser will surely display the Username and Password submitted by you.
[ August 03, 2006: Message edited by: Arun Somasundaram ]
 
Ram Kas
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have web.xml at all. Even then it is working fine after altering the following snippet



Thanks
 
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dinakar Kasturi:
I don't have web.xml at all. Even then it is working fine after altering the following snippet



Thanks



may i know how could you access the servlets from your web browser?

I have one question if it works fine. Can we use servelet name from web browser to get the output, without using web.xml??
 
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 rauhl roy:
[CODE]
I have one question if it works fine. Can we use servelet name from web browser to get the output, without using web.xml??



In older versions of the more popular servlet containers you could do this.
This turned out to be a bad idea for a host of different reasons and the capability has been pulled back.
So, in newer versions, the answer is no.
With Tomcat, this was done with the "InvokerServlet". To learn more about the InvokerServlet, read:
http://faq.javaranch.com/view?InvokerServlet
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic