Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link from html to jsp

Tags:

java

html

href

jsp

In dynamic Web Project I have - default.html page

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
    <a href="\WEB-INF\forms\CustomerMenu.jsp">Test new</a>

</body>
</html>

I have also the CustomerMenu.jsp page -

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link rel="stylesheet" href="./Styles/Site.css" type="text/css" />
<title>Create new customer</title>
</head>
<body>
    // Table ..
</body>
</html>

The pages hierarchy is as the snapshot -

enter image description here

When I press on the link in default.html I get error message

- HTTP Status 404 - 

--------------------------------------------------------------------------------

type Status report

message 

description The requested resource () is not available.
like image 496
URL87 Avatar asked Aug 02 '12 14:08

URL87


People also ask

Can you convert HTML to JSP?

Insert the following tag after the tag: <%= new java. util. Date() %>. The <% and %> are JSP tags that specify an action needs to be taken with the function that is provided.

How do you hyperlink in HTML?

Complete HTML/CSS Course 2022 To make a hyperlink in an HTML page, use the <a> and </a> tags, which are the tags used to define the links. The <a> tag indicates where the hyperlink starts and the </a> tag indicates where it ends. Whatever text gets added inside these tags, will work as a hyperlink.

Is JSP or HTML better?

JSP provides a dynamic interface for the continuously changing data and also it dynamically invokes the server actions. HTML provides a means to give a detailed account of the structure of text-based information in a document. JSP generated dynamic web pages only. Whereas Html generated static web pages only.


2 Answers

Files in /WEB-INF folder are not publicly accessible without using a front controller servlet or a specific tag like <jsp:include> which does either a RequestDispatcher#forward() or RequestDispatcher#include().

If you need to access a JSP file directly by URL, then you should not be placing the JSP in /WEB-INF folder. Put it outside the /WEB-INF folder

WebContent
 |-- forms
 |    |-- CreateNewCustomer.html
 |    |-- CustomerMenu.html
 |    `-- CustomerMenu.jsp
 |-- WEB-INF
 :    :

and fix the link accordingly.

<a href="forms/CustomerMenu.jsp">Test new</a>
like image 166
BalusC Avatar answered Oct 04 '22 16:10

BalusC


WEB-INF folder is not accessible outside. You will either need to move the jsp outside of WEB-INF or use forward request to forward to the jsp.

like image 39
evanwong Avatar answered Oct 04 '22 15:10

evanwong