| Author |
include file in jsp
|
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
How to include html file which is in static location in a jsp file
but getting error as The requested resource (/static/pjt/html/firstPage.htm) is not available
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
That's the way. You just need to give it the right URL.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Mary Chellapa
Ranch Hand
Joined: Jul 26, 2011
Posts: 93
|
|
And you need to put it in double quotes
and make sure the location of htm to be included is correct
|
Mary
|
 |
Piyush Joshi
Ranch Hand
Joined: Jun 10, 2011
Posts: 207
|
|
Use "file" attribute instead of "page":
<%@ include file="" %>
page attribute is for jsp standard action include:
<jsp:include page="" />
|
Piyush
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
Piyush Joshi wrote:Use "file" attribute instead of "page":
<%@ include file="" %>
page attribute is for jsp standard action include:
<jsp:include page="" />
Oops! That's right! Good catch.
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
The path of html file is correct but it is not being loaded from the static folder in the jsp page
Can anyone say me if it is possible to load and am I doing the correct process
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
Then the path can't be correct.
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
Bear Bibeault wrote:Then the path can't be correct.
The path is right. I created a hyperlink in the jsp page with the same path and able to re-direct when click on the link
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
Is you app deployed as the root web app?
If not, then it is definitely not right. A hyperlink needs to start with the context path, the include path does not. They'll be different except for when a web app is deployed as the root web app.
Insisting that it's right when it's not is not going to help you any. If it were right, it'd be working.
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
Bear Bibeault wrote:Is you app deployed as the root web app?
If not, then it is definitely not right. A hyperlink needs to start with the context path, the include path does not. They'll be different except for when a web app is deployed as the root web app.
Insisting that it's right when it's not is not going to help you any. If it were right, it'd be working.
yes, It is deployed as root.war folder
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
|
OK, so now it's time for you to show us the folder structure where the file is stored and the paths you are using to access it. Does the path work when you type it into the broser address bar?
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
Bear Bibeault wrote:OK, so now it's time for you to show us the folder structure where the file is stored and the paths you are using to access it. Does the path work when you type it into the broser address bar?
the Html file that I have created is in ROOT.war\static\pages\html and path that I am using to access is
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
Two things:
/static<%=request.getContextPath()%> is definitely wrong -- /static and the context path? What's that all about?Java scriptlets? In 2011? Really? Use the EL: ${pageContext.request.contextPath}
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
Bear Bibeault wrote:Two things:
/static<%=request.getContextPath()%> is definitely wrong -- /static and the context path? What's that all about?Java scriptlets? In 2011? Really? Use the EL: ${pageContext.request.contextPath}
Can you say me the path how to include in jsp file
inplace of scriplet I have to replace with el
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56554
|
|
When creating a client-side resource reference (images, css, scripts, etc), you start it with the context path. Fo example:
When creating server-side references (include, forwards) the context path is not included.
|
 |
ramu somu
Greenhorn
Joined: Oct 12, 2011
Posts: 20
|
|
Then how should I include the html page which tag do I have to use to include the html page which is in static folder in the jsp page
|
 |
 |
|
|
subject: include file in jsp
|
|
|