Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Error 404 in jsp  RSS feed

 
Siddique Ansari
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everyone, I am getting error 404 because of my address is wrong but i dont how to correct it. When I run my program using apache tomcat then it shows http://localhost:8080/SmsServices/Home.jsp but when i click on login button it goes to http://localhost:8080/LoginServlet while it should goto http://localhost:8080/SmsServices/LoginServlet. What to do?
my Web.xml file
 
Prajakta Acharya
Ranch Hand
Posts: 138
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post your JSP code here?
 
Siddique Ansari
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>PlzDo.it</title>

<base href="${pageContext.request.contextPath}">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/style.css">

<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>

<body>
<%
String uname=(String) request.getSession().getAttribute("uid");
if(uname!=null){
System.out.println("UID =" +uname);
response.sendRedirect("UserHome.jsp");
return;
}
%>

<br>
<br>

<section class="container">
<div class="login">

<form method="post" action="LoginServlet">
<p>${message}</p>
<c:remove var="message" scope="session" />
<p>${errMsg}</p>
<c:remove var="errMsg" scope="session" />

<p><input type="text" name="name" value="" placeholder="Username"></p>
<p><input type="password" name="password" value="" placeholder="Password"></p>
<p class="remember_me">
<label>
<input type="checkbox" name="remember_me" id="remember_me">
Remember me on this computer
</label>
</p>
<p class="submit">
<input type="submit" value="Login"></p>
</form>

<form action="/CreateUser.jsp" method="post">
<p class="submitt">
<input type="submit" value="Sign Up">
</p>
</form>

</div>

<div class="login-help">
<p>Forgot your password? <a href="index.html">Click here to reset it</a>.</p>
</div>
</section>


</body>
</html>
 
jagrutkumar dalwadi
Ranch Hand
Posts: 83
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By looking at your error it seems that it is servlet configuration issue.

Correct configuration would be as below:

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/SmsServices/LoginServlet</url-pattern>
</servlet-mapping>

Reason: If we are putting "/" before url pattern, container understands that request should start from the servlet context. However that we dont want in this case.
 
Siddique Ansari
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jagrutkumar dalwadi wrote:By looking at your error it seems that it is servlet configuration issue.

Correct configuration would be as below:

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/SmsServices/LoginServlet</url-pattern>
</servlet-mapping>

Reason: If we are putting "/" before url pattern, container understands that request should start from the servlet context. However that we dont want in this case.

Then Home.jsp is also giving not found error.
 
jagrutkumar dalwadi
Ranch Hand
Posts: 83
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is defined in to the welcome file list. If possible, please try.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!