This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Servlet error  RSS feed

 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator






I guess I think everything fine in this program but i am getting an error when the click the login button in html page. What I mean is the page is not navigating to the Login servlet. Kindly, post if an y mistak eis there.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


We get one or more of these a week ... see the Servlets FAQ here at the ranch to prevent more beginner mistakes.

This one is due to your servlet class not being in a package. ALL classes used in servlets MUST be in a named package because otherwise the JVM looks in the "current" directory for the class file.

Bill
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But even after that I am not getting the output sir.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell us what changes you have made, and what, exactly, is happening now, and how that differs from what you expected to happen.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made this change , but even now the servlet is not found using the url-pattern.
getting an error message as web-page cannot be found
<servlet-name>Login</servlet-name>
<servlet-class>Servlet.Login</servlet-class>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that the only change you made? Did you put the package statement in the servlet? Is the class file in the proper folder? TellTheDetails please.

Also, the package name "Servlet" is a poor choice; it is not only not very descriptive, it does not follow the convention of being all lowercase.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah i imported the package in servlet sir..
but still I didnt get the output
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you refuse to cooperate and show us (don't tell us, show us) the changes you have made, then there's likely not much more we can do to help.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok , I apologize
Here is the modified code.




 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the context path of the web app? You need to include it in the form action.

Also, package names should be all lowercase. All lowercase.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
context path??


just url path enough right??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, if it were, I wouldn't have said that the context path is needed.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir< i gave the context path in form action as

<form action ="/Blog-Show/log">

and even changed the package name to small letters but got the same result
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, getting closer. I assume that /Blog-Show is the correct context path? Have you used the Tomcat Manager app (assuming Tomcat) to verify that the context has been properly deployed?

By the way, what error are you getting? We've all been assuming a 404. But TellTheDetails.
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied the project folder from my myeclipse workspace and deployed in tomcat when the clicked my project link name Blog_Show I got a 404 error. But in myeclipse atleast welcome-file is getting displayed.
I don't know where I made a mistake
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Have you used the Tomcat Manager app (assuming Tomcat) to verify that the context has been properly deployed?
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah i checked now, its properly deployed but the thing is not moving to servlet file using the provided url.. getting an 404 error
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi @Bear Bibeault

I got the output when i deployed the project in tomcat,
I gave the directory structure as

Blog_Show
|
|--WEB-INF
| |
| |--classes
| |
| |--Login.java and Login.class file(within the classes folder)
|
|------Welcome.html


in form action I just gave <form action ="log">

when I gave the exact mapping as /log i got a error 404 status as - /log (requested resource is not available)
 
Karthikeyan Pandian
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even in eclipse i got made a silly mistake..

thank you sir @Bear Bibeault
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!