Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

My login form using servlet is not showing any output  RSS feed

 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam unable to view my login form using servlet
below are my files....
***************************************************************************
LoginServ.java
***************************************************************************

************************************************************************************************
Validate.java
*****************************************************************************************************


*****************************************************************************************************
WelcomeServ
**************************************************************************************************************************************************************

*****************************************************************************************************************************
index.html
**********************************************************************************************************************************

************************************************************************************************************************
web.xml
***********************************************************************************************************************


*****************************************************************************************

i tried ruuning my LoginServ file and i get no error but i also i am not getting any output..(loging page)

please suggest your solutions to this problem

[edited to add code tags]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch! I've edited your post to add code tags to make it easier to read.

I suspect that there are in fact log messages; just not where you are looking. Let's try a test. Replace your doPost() with this one which contains a debugging statement. Then redeploy and check the logs again. If you don't see the test println in the logs, post what server you are using and where you are looking.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, what are you expecting this line of code to do? (It doesn't).
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne Boyarsky
thank you for the reply..
i tried replacing my do post method with what you gave me

and when i tried running the LoginServ file it still doesnot show any output...and iam not getting any error in console
well the line

i have attached my output screen kidnly view it to get a better picture of my problem
thank you
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Request Dispatcher doesn't take an arbitrary string nor print it out.

As far as the logs, what directory are you looking in for "test can see error messages". It's not going to appear on the screen. It is going to appear in your server's output. What are using? Tomcat? JBoss? Jetty? Something else?
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ Jeanne Boyarsky
i am using tomcat version 7
well i thought request dispatcher would print some message.thanks for the information.
well i ran my file with your code all i get in my server is server started there is nothing else seen like "test can see error messages"
i get the following mesage in server
Jul 26, 2014 5:44:42 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Java\jdk1.7.0_60\bin;.
Jul 26, 2014 5:44:42 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ServletLevel2' did not find a matching property.
Jul 26, 2014 5:44:43 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8082"]
Jul 26, 2014 5:44:43 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 26, 2014 5:44:43 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1079 ms
Jul 26, 2014 5:44:43 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 26, 2014 5:44:43 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Jul 26, 2014 5:44:44 PM org.apache.catalina.util.SessionIdGenerator createSecureRandom
INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [105] milliseconds.
Jul 26, 2014 5:44:44 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\docs
Jul 26, 2014 5:44:44 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\docs has finished in 79 ms
Jul 26, 2014 5:44:44 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\examples
Jul 26, 2014 5:44:45 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 26, 2014 5:44:45 PM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 26, 2014 5:44:45 PM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@5710fdb4')
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\examples has finished in 804 ms
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\host-manager
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\host-manager has finished in 115 ms
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\manager
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\manager has finished in 110 ms
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\ROOT
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\ROOT has finished in 100 ms
Jul 26, 2014 5:44:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8082"]
Jul 26, 2014 5:44:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 26, 2014 5:44:45 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2253 ms


i dont see anything on server and there is no error...
my idea is i want to create a login from using html and when i run my servlet it should show be login page where i can enter the valid emaiId and password present in my database. when i login successfully it should display some message.

please help me achieve this goal
thank you.
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne Boyarsky
i was able to run my file..previously i was trying to run LoginServ file which is my servlet..but i was supposed to run index.xml
now when i run my index.html i got the login form..
but when i entered a valid user name and password in the form and pressed on submit button i got i got http status 404 error
.
error http status 404:Servletlevel2/LoginServ "The requested resource is not found"

following is my updated code

index.html


LoginServ.java


Validate.java


WelcomeServ.java


web.xml


iam using apache tomcat server version 7

kindly solve my problem
thank you...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good. Progress.

These are inconsistent:

<form method="post" action="LoginServ">

<url-pattern>/login</url-pattern>

The web.xml says it will call the login servlet when you have the URL /login. But the form submits the URL LoginServ. LoginServ is just the name within your web.xml. Try changing the HTML to match your web.xml.
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne Boyarsky

i did change my index.html file by giving the url pattern of web.xml but iam still getting the same error when i enter valid emailId and password and click on submit button

index.html



web.xml
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your web app have a context root? If so, you need that before /login.
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Jeanne Boyarsky
iam a noob in servlets
so i didnot understand by context root in my web app...do you mean web.xml file??

web.xml
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@@Jeanne Boyarsky

here is my folder structure in eclipse
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i couldnot attach the image of my folder structure

below is my fodler structure

ServletLevel2 //my project
-Java Resources
-src
-com.peg.servUserLogin
-LoginServ.java
-Validate.java
-WelocmeServ.java

WEB-INF
-lib
-web.xml
-index.html


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something seems wrong here; the index.html is in a protected location that shouldn't be available. What URL do you use to get to the HTML page? You want it to be something like: http://localhost:8080/myApp/index.html.
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well i have made changes to my code.iam able to enter emailId and password and click on submit button when i hit submit button iam getting httpstatus 500 error message in eclipse.iam sure there is problem with code after the line "String pwd = request.getParameter("password");" in LoginServ.this is because when i replace the method returnUserInfo with method Validate user it is login in but it is not validating . i will post the code using two different methods below:

note: the LoginServ.java is being called and it is enterting into the dopost method and printing "Hello cutepie your mail id is:" but it is failing after this...because when i print a simple message in dopost witout any logic it is printing that message..

version 1
index.html



web.xml


LoginServ.java using returnUserInfo method



Validate.java



WelcomeServ.java


Myfile structure is as follows:
ServletLevel2 //my project
-Java Resources
-src
-com.peg.servUserLogin
-LoginServ.java
-Validate.java
-WelocmeServ.java

WEB-INF
-lib
-web.xml
-index.html


The full stack trace of the root cause which is available in the Apache Tomcat/7.0.54 logs is as follows:

127.0.0.1 - - [26/Jul/2014:21:27:29 -0700] "GET / HTTP/1.1" 200 11418
127.0.0.1 - - [26/Jul/2014:21:27:30 -0700] "GET /ServletLevel2/index.html HTTP/1.1" 200 491
127.0.0.1 - - [26/Jul/2014:21:27:36 -0700] "POST /ServletLevel2/login HTTP/1.1" 500 1432




*************************************************************************************************************************************************************************************
version 2 code
iam able to login but when i click on submit button iam getting the message"Hello cutepie your mail id is: hr You have entered wrong emailId or password " and iam redirected to index.html page

index.html


web.xml


LoginServ.java using validateUser method



Validate.java


WelcomeServ.java



kindly suggest me a solution to my problem... you could deploy my code in your system and see what is the exact problem.thank you for spending your valuable time and for your patience....
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is suprising....
well i have made a separate class and deployed my validateUser method and when i run it i get the return value as true with valid emailId and password and with invalid emailId and password it returning false value.
but the same method when i am trying to use it in LoginServ.java it is returning always boolean value false



please help me guys !!
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sampath,
Have you checked your log files if an exception does not occur?
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI
yes i have run my servlet program using the version 2 code which is using the ValidateUser method i dont get any errors in my log file: log file is as follows:
Jul 27, 2014 10:01:05 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\oraclexe\app\oracle\product\11.2.0\server\bin;;C:\Program Files\Broadcom\Broadcom 802.11 Network Adapter;;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\Java\jdk1.7.0_60\bin;.
Jul 27, 2014 10:01:05 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:ServletLevel2' did not find a matching property.
Jul 27, 2014 10:01:05 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:samJdbcFirstApp' did not find a matching property.
Jul 27, 2014 10:01:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8082"]
Jul 27, 2014 10:01:05 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jul 27, 2014 10:01:05 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1045 ms
Jul 27, 2014 10:01:05 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jul 27, 2014 10:01:05 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Jul 27, 2014 10:01:07 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\docs
Jul 27, 2014 10:01:07 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\docs has finished in 73 ms
Jul 27, 2014 10:01:07 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\examples
Jul 27, 2014 10:01:08 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: contextInitialized()
Jul 27, 2014 10:01:08 AM org.apache.catalina.core.ApplicationContext log
INFO: SessionListener: contextInitialized()
Jul 27, 2014 10:01:08 AM org.apache.catalina.core.ApplicationContext log
INFO: ContextListener: attributeAdded('org.apache.jasper.compiler.TldLocationsCache', 'org.apache.jasper.compiler.TldLocationsCache@969f4cd')
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\examples has finished in 510 ms
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\host-manager
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\host-manager has finished in 112 ms
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\manager
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\manager has finished in 77 ms
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory D:\apache-tomcat-7.0.54\webapps\ROOT
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deployment of web application directory D:\apache-tomcat-7.0.54\webapps\ROOT has finished in 62 ms
Jul 27, 2014 10:01:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8082"]
Jul 27, 2014 10:01:08 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jul 27, 2014 10:01:08 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2665 ms



though iam entering a valid emaildId and password in the fields and clicking on submit button iam getting this message:
"Hello cutepie your mail id is: hr You have entered wrong emailId or password"

 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can someone deploy my code into your system and see whats wrong please i have been trying to fix this bug since yesterday morning .....and iam not getting any sleep since i dont find solution i love coding please help
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is difficult to test your pages because we don't have the your database. change your exception blocks to look like this:

Do the same for the other exceptions in Validate.java and try again to see if there is something printed in log.
And is 'hr' a valid email of a user in registeruser?
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Paul Ngom

well as i said i used the same method ValidateUser() is working fine when i place it in a new class and run...it is returning true if i give valid emailId and password but when i place the same method in the servlet and call it in my ServLogin.java it is giving only false value no matter i give a valid email and password or invalid email and password. yes emailId="hr" and password="hr" are valid ..i checked in my database ..they are present in the table "registeruser". ans also dopost method of my servlet LoginServ is being called..as when if i give a print statment before calling validateUser() it is printing that message.
 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you add the system.out.println(...) in your catch blocks as i indicated?
And i noticed this line:

inside your Validate.java, does it appear in your log?To verify, delete everything in log. Test again and see if that line will be printed in log.
 
Sampath Thigulla
Greenhorn
Posts: 21
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys...
i have fixed my issue
my code was correct but i was getting the error because i dint had had ojdbc6.jar in my folder "D:\apache-tomcat-7.0.54\lib"
So when i placed the ojdbc6.jar file in apachetomcat/lib and tried running my servlet i got it right. it displayed a welcome message for valid emailId and password and error message for invalid emailId and password
thanks guys for your valuable time ..

 
Paul Ngom
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bravo!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!