[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

anchor tag href to another jsp page is not working

Posted on 2011-10-04
4
Medium Priority
?
1,400 Views
Last Modified: 2012-05-12
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
Comment
Question by:lakkarajumurali
  • 2
4 Comments
 

Author Comment

by:lakkarajumurali
ID: 36912413
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
 
LVL 28

Accepted Solution

by:
rrz earned 2000 total points
ID: 36914508
>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
 
LVL 10

Expert Comment

by:Pramod Kumar
ID: 36916117
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
 

Author Comment

by:lakkarajumurali
ID: 36920119
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question