• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2104
  • Last Modified:

anchor tag href to another jsp page is not working

hi,

I have a very basic problem here it is http 404 error, when i try to open the index_old.jsp page from index.jsp.  Both files are in the WEB-INF/jsp folder.  Here is the index.jsp file looks like.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
      <div>
            <ul>
                  <li><a href="index_old.jsp" target="_blank" >Security SignOn Data</a></li>
            </ul>
      </div>
</body>
</html>

and the index_old.jsp is like this;

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body> Hi there!!  </body>
</html>

the web.xml is as shown below:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Tremor Web Application</display-name>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
   
  <welcome-file-list>
    <welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
  </welcome-file-list>

</web-app>

i suspect there is some problem with the anchor tag href which is failing to show up the index_old.jsp but i could not figure what it is? Can anyone please help me fix this.

0
lakkarajumurali
Asked:
lakkarajumurali
  • 2
1 Solution
 
lakkarajumuraliAuthor Commented:
another info, when i add the index_old.jsp in the welcome-file-list tag in the web.xml, it is opening up the index_old.jsp page but it is throwing http 404 error which trying to access through index.jsp.

this shows the index_old.jsp but i dont want this i want index.jsp as the welcome-file for my application.

  <welcome-file-list>
        <welcome-file>/WEB-INF/jsp/index_old.jsp</welcome-file>
    <welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
  </welcome-file-list>
0
 
rrzCommented:
>Both files are in the WEB-INF/jsp folder.  
Why are you placing your JSPs in WEB-INF  ?
The WEB-INF folder is not available to a browser.
Normally, JSPs are placed in the root folder(or a sub-folder of the root folder) of a web app.  
0
 
Pramod KumarCommented:
I agree with rrz@871311

Also, if you design forcing you to keep JSP under WEB-INF then you should write a servlet which can pass/forward the request to respective jsp file

    request.getRequestDispatcher("WEB-INF/index.jsp").forward(request, response);  
0
 
lakkarajumuraliAuthor Commented:
I placed the index.jsp under war/jsp folder the web-inf is also under war.  Now the <a tag is forwarding me to index_old.jsp.

thank you for the reply.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now