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

Problem with simple HTML - Servlet login

 
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

If i open http://localhost:8080/EETest-war/servlet/LoginServer i get a simple html login page:


When i press the submit button, i get the page not found error. I've tried every possible combination in action="". Maybe someone can point out what i do wrong, here is the web.xml:


And the servlet:


I really hope someone can help, i'm stuck :P Thank you
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
change the form action to



edited : i hadn't seen the current page location .

avi sinha
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have an HTML file defined as a servlet?

Why did you bother to write the servlet if you are not going to use it?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

avi sinha wrote:change the form action to

No. Do not.

Relative paths are a disaster. Your paths should always start with the context path.

What needs to be fixed is the deployment descriptor.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:

avi sinha wrote:change the form action to

No. Do not.

Relative paths are a disaster. Your paths should always start with the context path.

What needs to be fixed is the deployment descriptor.



meanwhile you were typing . i corrected sir. my mistake.

avi sinha
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry sir again.
i thought the location stated above is the location for the html file from where post method is being called .

DD should be



and the html file should be



avi sinha
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the answer. With the new settings i get this error:

HTTP Status 404 -

type Status report
message
descriptionThe requested resource () is not available.

I don't even get the Login screen anymore, i just get this error.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What new settings? If you don't show them, how can we help?

And one crucial piece of information you haven't yet supplied: what is the context path?
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ones avi sinha posted.

Edit: Context path is /EETest-war
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parvan Alexandru wrote:Thanks for the answer. With the new settings i get this error:

HTTP Status 404 -

type Status report
message
descriptionThe requested resource () is not available.

I don't even get the Login screen anymore, i just get this error.



the reason is that you haven't defined the mappings for the servlet you are trying to use.
the mapping you have provided in the DD is for the jsp file not for the servlet.

avi sinha
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please show me what i should write so it can run ? I'm learning the hang of it and it would be easier if i had the correct version so i can see what i'm missing.

Thank you.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Those are not correct. What is the purpose of the jsp-file entry?

Declaring a servlet is as simple as:


And, your servlet must be in a package.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parvan Alexandru wrote:Could you please show me what i should write so it can run ? I'm learning the hang of it and if i don't see the correct version, i really don't understand what i'm missing.

Thank you.



at first tell me these things then we can help :

1> name of your web-app. is it servlet no its /EETest-war. am i right??
2> name of the first html page you are using to call the post method of servlet
3> package structure of the servlet class i.e. where have you kept the class file ?

avi sinha
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using NetBeans. The project name is EETest and it's using EETest-war as a client module (that's where all the files are).

C:\Users\Infernal\Documents\Java\EETest\EETest-war\build\web\WEB-INF\classes - the class folder

pub_login.html - the first html page

I attached a screen with the project.
Untitled.jpg
[Thumbnail for Untitled.jpg]
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:And, your servlet must be in a package.


Why ? I'll try...
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parvan Alexandru wrote:

Bear Bibeault wrote:And, your servlet must be in a package.


Why ? I'll try...



otherwise you will not be able to use it as per the specification.

avi sinha
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you are trying to learn servlets using Netbeans or any other ide , you are doing it wrong.
there are a lot of concepts you should know and i bet you can't learn them using an ide .
so my suggestion is :
try to do it without using an ide. and its quite traumatic for us to help you if you are using an ide.

avi sinha
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok i am trying again . hope you can understand

html file Loginserver http://localhost:8080/EETest-war/servlet/LoginServer


DD:



and put the LoginServlet class file in WEB-INF-->com-->web-->
and restart the server
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried tutorials, books, they all explain it in a different way, and it never works. NetBeans does some of the work for me and it's the first time i got this far.

I can't get server-class right, if it's in package "pack", shouldn't it look like this:
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parvan Alexandru wrote:I have tried tutorials, books, they all explain it in a different way, and it never works. NetBeans does some of the work for me and it's the first time i got this far.

I can't get server-class right, if it's in package "pack", shouldn't it look like this:



i have posted the correct code for your app . check that.
and mind it : its the Netbeans who is doing your work not you. grab a copy of head first servlets and jsp and i am sure you will do it on your own.

avi sinha
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still get the same error

HTTP Status 404 -

type Status report
message
descriptionThe requested resource () is not available.

Without getting the login screen. Isn't this wierd ?

I really want to thank you for your patience with me.
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Parvan Alexandru wrote:I still get the same error

HTTP Status 404 -

type Status report
message
descriptionThe requested resource () is not available.

Without getting the login screen. Isn't this wierd ?

I really want to thank you for your patience with me.



ok wait for a while i am going to code a small web-app for you to make you understand the whole scenario.

avi sinha
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sample web-app

unzip the file in your server's web-app directory and then in your browser open up http://localhost:8084/TestServlet/web
please restart the server before opening the page
avi sinha
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now i get:

HTTP Status 405 - HTTP method GET is not supported by this URL

type Status report
messageHTTP method GET is not supported by this URL
descriptionThe specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

Anyway, i'll try more tomorrow (it's almost 3 AM here), i'll figure it out in the end. Thanks for the help.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at your servlet. It's quite clear why you get that message.
 
Alex Parvan
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've done it. And with your help, thank you so much.
First of all, i have to access http://localhost:8080/EETest-war where the login page is at. And when i press the submit button, it calls /EETest-war/Login.

Here is my final code:

Servlet:


HTML:


web.xml file:


Thank you soooo much !
reply
    Bookmark Topic Watch Topic
  • New Topic