1

I am a novice developer working with servlets. I am using STS4.0 with Apache 9. I have a login html page that takes username and pw and calls a login method in LoginController. I defined the servlet mapping in webxml as follows:

<welcome-file-list>
    <welcome-file>/login.html</welcome-file>
    <welcome-file>/index.htm</welcome-file>
</welcome-file-list> 
  
 <servlet>
    <display-name>LoginController</display-name>
    <servlet-name>LoginController</servlet-name>
    <servlet-class>controller.LoginController</servlet-class>
 </servlet> 
    
 <servlet-mapping>
   <servlet-name>LoginController</servlet-name>
   <url-pattern>/servleturl</url-pattern>
 </servlet-mapping>
project structure is as follows:
log (project)
--controller (package)
------LoginController

I am getting the error "The requested resource [/servleturl] is not available".  My login html file 
looks like this:
<html>
<head>
<meta charset="ISO-8859-1">
<title>Front Controller </title>
<link rel="stylesheet" type="text/css" href="/log/resources/mystyles.css"/>
</head>
<body>
<div class="login-container">
    <form method="GET" action= "/servleturl">
        <p>Please log in with user name and password</p>        
        <input type="text" placeholder="enter username" name="username"/>
        <br>
        <input type="submit" value="Login"/>
    </form> 
</div>
</body>
</html>

Any help is greatly appreciated.

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
user28
  • 11
  • 1

1 Answers1

-1
  • Make sure about form data and servlet @RequestParam
  • if servlet Params, not matches it shows not found

You have missed password input in above code snippet you have given

<form method="GET" action= "/servleturl">
    <p>Please log in with user name and password</p>        
    <input type="text" placeholder="enter username" name="username"/>
    <br>
    <input type="password" placeholder="enter password" name="password"/>
    <input type="submit" value="Login"/>
</form>