• 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

calling jsp from html

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
do i need to add anything in my web.xml? I'm using apache tomcat 7 for web server
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
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
Here's an article that outlines how to properly structure Java web apps: this article
 
Bartender
Posts: 1845
10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey yes, i got to use servlet and it works. thank you guys
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic