• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

include file in jsp

 
ramu somu
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's the way. You just need to give it the right URL.
 
Mary Chellapa
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And you need to put it in double quotes
and make sure the location of htm to be included is correct
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use "file" attribute instead of "page":
<%@ include file="" %>

page attribute is for jsp standard action include:
<jsp:include page="" />
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then the path can't be correct.
 
ramu somu
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64618
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Pie
    Posts: 64618
    86
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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
    Posts: 20
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator


    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
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic