• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Error 404 in jsp

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 138
Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post your JSP code here?
 
Siddique Ansari
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Ranch Hand
Posts: 83
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is defined in to the welcome file list. If possible, please try.
 
Their achilles heel is the noogie! Give them noogies tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic