I have recently started working on web applications and was trying to set up a practise project to try out different things. But I am stuck at a very initial stage and I googled a lot but could not find the solution to my problem. I have associated the project with an EAR project and the ear is deployed on the server.
This is the project setup I am facing problems with :
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>College Administration</display-name>
<servlet>
<servlet-name>loginServlet</servlet-name>
<servlet-class>kumar.suraj.college.administration.login.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>loginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
</web-app>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
<display-name>web-college-administrationEar</display-name>
<module>
<web>
<web-uri>web-college-administration.war</web-uri>
<context-root>web-college-administration</context-root>
</web>
</module>
</application>
glassfish-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish- web-app_3_0-1.dtd">
<glassfish-web-app>
<context-root>web-college-administration</context-root>
</glassfish-web-app>
login.jsp
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login Page</title>
</head>
<body>
<form name="login" action="login" method="post" accept-charset="utf-8">
<label for="usermail ">Email</label>
<input type="email" name="usermail" placeholder="yourname@email.com" required>
<br/>
<label for="password ">Password</label>
<input type="password" name="password" placeholder="password" required>
<br/>
<input type="submit" value="Login">
</form>
</body>
</html>
LoginServlet.java
package kumar.suraj.college.administration.login;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class LoginServlet
*/
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public LoginServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doGet(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
response.getWriter().append("Hello Suraj");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doPost(final HttpServletRequest request, final HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
this.doGet(request, response);
}
}
The login.jsp is placed in WebContent/WEB-INF folder of my project.
When I hit the url http://localhost:53809/web-college-administration/login
I get the following out put "Served at: /web-college-administrationHello Suraj" as per the doGet method of LoginServlet.java.
But when I hit the url http://localhost:53809/web-college-administration/login.jsp I get the following error :
HTTP STATUS 404 - NOT FOUND
type status report
message Not Found
description The requested resource is not available.
And in eclipse console I get the following message :
2016-07-03T16:34:18.969+0530|Severe: PWC6117: File "null" not found.
Could someone please tell me what is wrong with my setup ?