• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Can't access HTML form page in browser

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On running the servlet as "Run as Run on server", i am getting the html designed by my servlet. However i cannot get the html form page (that i have manually created to take data) on browser. Please help....
Servlet : LoginServlet.java
Form : login.html

XML file:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd"> -->
<web-app xmlns:javaee="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>Hello</servlet-name>
<servlet-class>com.sapient.rose.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Hello</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>

</web-app>
 
Sheriff
Posts: 22802
131
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Can you show us your form's opening element?
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hiiiiiii.....

this is my form/html :



 
Ranch Hand
Posts: 31
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>>>Servlet : LoginServlet.java

Can you please post LoginServlet as well.
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
LoginServlet.java



The output i get is :

Thanks Mr. null
Now you can see your password : null

And the url for the above output is:

http://localhost:8080/Testing_Project/LoginServlet

Please help

 
Ranch Hand
Posts: 1143
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
checkout the action of your form, because for me your code is working correctly...
i m getting the output is:

Thanks Mr. punit
Now you can see your password : punit
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Punit, i wanna know how exactly are you reaching the form/html page . Are you running LoginServlet.java , simply as "Run as -> Run on server".
Please post the url you are getting for the form/html page.
I think i have something wrong with my web.xml
Can you show your web.xml as well


 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
form1.html


TestForm.java


web.xml


url m using is:

http://localhost:8080/passValueProblem/form1.html

i m using eclipse.

hope this helps.
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Punit for uploading these files.
But i am still confused.

You haven't given the fully qualified name of your class in web.xml. On my machine it does not even loads the html created by my servlet.
However, when i give the fully qualified name of class it shows the same null output, again.

Also regarding the url that you have provided. It gives a 404 error on the browser. I have the same port and everything........
I don't understand how the url does not have any mention of the project name.

To be more elaborate....
I am creating "Dynamic Web Project"
A package in src -> com.sapient.rose -> New Class ("LoginServlet.java")
form1.html and web.xml in WEB_INF

Even i am using Eclipse (Version: Indigo Service Release 2)

And i haven't been able to access my form/html page yet.

Can you specify your project structure and how exactly do you run your code.
Please bear with me a little more........

 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Punit is not using fully qualified name in his web.xml because his servlet exists in the default package.
Something interesting in his post is the following line

Punit Jain wrote:
url m using is:

http://localhost:8080/passValueProblem/form1.html


So he is typing in the URL of the HTML page, not the servlet.

From your post,

Qualter Demix wrote:The output i get is :

Thanks Mr. null
Now you can see your password : null

And the url for the above output is:

http://localhost:8080/Testing_Project/LoginServlet


Its clear that your servlet is generating the output, only thing it complains is that it was not able to read the parameters from the request, this is because there was no request!!

And for the 404, you might need to look closer at

Qualter Demix wrote:


Do you notice something??

Hope this helps
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for narrowing down the problem........
So,

this is because there was no request!!


means that i am not able to send any request
I did my research and in one example i found this....

To debug a HTML form set its 'action' attribute to refernce the Servlet

So, in Punit's example

<form method="GET" action="TestForm">

action=Servlet reference (<servlet-name> in web.xml) ....

Still, after using the url: http://localhost:8080/passValueProblem/form1.html
i am getting 404 error....

NEED MORE HELP
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

You haven't given the fully qualified name of your class in web.xml. On my machine it does not even loads the html created by my servlet.
However, when i give the fully qualified name of class it shows the same null output, again.



This is because i m using the default package, i have not created any package, as you have created com.sapient.rose..

Also regarding the url that you have provided. It gives a 404 error on the browser. I have the same port and everything........
I don't understand how the url does not have any mention of the project name.



this is also because i have the default package and you have created a package, and you have created.


I am creating "Dynamic Web Project"
A package in src -> com.sapient.rose -> New Class ("LoginServlet.java")
form1.html and web.xml in WEB_INF



I am also using the same procedure but i m doing all this in default package...
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Still, after using the url: http://localhost:8080/passValueProblem/form1.html
i am getting 404 error....



you have to give your package name as well, if you are not doing this all in default package..
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Punit i am still getting 404 error on typing this url after running my servlet class

http://localhost:8080/passValueProblem/form1.html



i did some more research and i found this:

The portion of the URL after the http://host:port +WebAppName is compared to the <url-pattern> by WebLogic Server

The url i am getting is : http://localhost:8080/Punit_Project/TestForm (Punit_Project being my "Dynamic Web Project")
Therefore if i don't give any WebAppName it takes the project name as the WebAppName.

In your url passValueProblem must be the WebAppName.

So, can i safely conclude that </display-name> attribute in web.xml defines the WebAppName ???
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Qualter Demix wrote:Punit i am still getting 404 error on typing this url after running my servlet class

http://localhost:8080/passValueProblem/form1.html



I don't get what running the servlet class actually means. You don't run it, you deploy it on the server.
The HTML page has nothing to do with the servlet, it will be displayed in the browser if it is present at the correct location on the server.

Will you please post your directory structure from the root of your web-app?
I think Eclipse is generating the right folder structure and all but the HTML file is located at a wrong location.

 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Qualter Demix wrote:
means that i am not able to send any request

Still, after using the url: http://localhost:8080/passValueProblem/form1.html
i am getting 404 error....



It means there is no request which has the form data the servlet is trying to read.

Here the web-app name passValueProblem is important, so is the name of the HTML file and its location.
Have you cross checked if they are all correct?
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My directory structure is:

/Punit_Project/src/TestForm.java
/Punit_Project/WebContent/WEB-INF/web.xml
/Punit_Project/WebContent/form1.html

and to deploy i simply (Run as->Run on server) on TestForm.java
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you select Run on server, then a new browser window is opened, whatever address you get there, just remove your servlet's name and add form1.html after the last slash(/).
So for example if the URL displayed is http://localhost:8080/some_project/LoginServlet, change it to http://localhost:8080/some_project/form1.html.
This has to work if the servlet and HTML file are part of the same web-app that is the same web project in eclipse.
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Amit.............thanks a lot......i got the HTML/form page
it is working.............
 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome Qualter
Are you also able to get the parameters you entered in the form on the servlet's response page instead of null values?
 
Qualtar Demix
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i am getting the values as well.

 
Amit Ghorpade
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good work Qualter, keep it going!!
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic