This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes Help me please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help me please" Watch "Help me please" New topic
Author

Help me please

Ram Kas
Ranch Hand

Joined: Jul 26, 2006
Posts: 83
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
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

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.


GenRocket - Experts at Building Test Data
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
1. your opening form tag.

2. you need web.xml also when you are working with servlet.
Ram Kas
Ranch Hand

Joined: Jul 26, 2006
Posts: 83
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

Joined: Jul 26, 2006
Posts: 83
Thanks rathji
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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 ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
vjy chin
Ranch Hand

Joined: Feb 17, 2005
Posts: 279
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

Joined: Aug 25, 2005
Posts: 536
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


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
Arun Somasundaram
Ranch Hand

Joined: Jul 25, 2006
Posts: 63
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 ]

Arun.V.Somasundaram
Ram Kas
Ranch Hand

Joined: Jul 26, 2006
Posts: 83
I don't have web.xml at all. Even then it is working fine after altering the following snippet



Thanks
Rauhl Roy
Ranch Hand

Joined: Aug 01, 2006
Posts: 401

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

Joined: Dec 11, 2004
Posts: 13410

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
 
 
subject: Help me please
 
Similar Threads
Progress bar on IE6
Urgent : Servlet to Servlet(in another server)
if (req.getMethod().equals("HEAD")) return
Requested Dispatcher
Internal service error..