• Post Reply Bookmark Topic Watch Topic
  • New Topic

calling jsp from html  RSS feed

 
Claire Chan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm having "description The requested resource is not available" error for calling jsp page from my html form:

my form from html page is here :

<form action="/login.jsp" method="post">
<table border="1" width="30%" cellpadding="3">
<thead>
<tr>
<th colspan="2">Login Here</th>
</tr>
</thead>
<tbody>
<tr>
<td>User Name</td>
<td><input type="text" name="user" value="" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pass" value="" /></td>
</tr>
<tr>
<td><input type="submit"/></td>
</tr>
</tbody>
</table>
</form>
---
I don't know what's wrong calling jsp login page from html. any pointer would be appreciated.

Thanks
jsperror.JPG
[Thumbnail for jsperror.JPG]
JSP Error
 
Claire Chan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do i need to add anything in my web.xml? I'm using apache tomcat 7 for web server
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP should not be called directly like that.
Request should always go to a Servlet and it is the responsibility of the Servlet to forward the request to JSP.

JSP should be created inside WEB-INF directory so that it cannot be accessed directly.
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have a slash "/" in front making it looking at localhost:8080/login.jsp rather than inside your webapp.

As Tapas suggested, you ought to use a servlet and forward/redirect to the login jsp page.

If login page is your default page, you may set it in web.xml welcome page so the first page the app loads will be login page.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's an article that outlines how to properly structure Java web apps: this article
 
Stefan Evans
Bartender
Posts: 1836
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:You have a slash "/" in front making it looking at localhost:8080/login.jsp rather than inside your webapp.



I thought so too - but take a closer look at the screenshot - the 404 error is for http://localhost:8080/SampleJSP/login.jsp

So Claire - can you give us a bit more information?

What are the files in your web application?
Which directories are they in relative to the Tomcat installation directory?
What is the URL of your HTML page?


From your screenshot, for things to work I would expect to see the following files at least:
[TOMCAT_HOME]/webapps/SampleJSP/login.jsp
[TOMCAT_HOME]/webapps/SampleJSP/WEB_INF/web.xml

 
Claire Chan
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey yes, i got to use servlet and it works. thank you guys
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!