• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

include file in jsp

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's the way. You just need to give it the right URL.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 207
jQuery Eclipse IDE Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then the path can't be correct.
 
ramu somu
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67749
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
    Sheriff
    Posts: 67749
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
      Number of slices to send:
      Optional 'thank-you' note:
    • 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
     
    reply
      Bookmark Topic Watch Topic
    • New Topic