Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help me please

 
Ram Kas
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • 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?
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Thanks rathji
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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 ]
 
vjy chin
Ranch Hand
Posts: 279
  • Mark post as helpful
  • send pies
  • 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.
 
Richard Green
Ranch Hand
Posts: 536
  • Mark post as helpful
  • send pies
  • 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
 
Arun Somasundaram
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Rauhl Roy
Ranch Hand
Posts: 401
Spring
  • Mark post as helpful
  • send pies
  • 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 Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic