aspose file tools*
The moose likes JSP and the fly likes problem in relative path in jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in relative path in jsp page" Watch "problem in relative path in jsp page" New topic
Author

problem in relative path in jsp page

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

I am facing problem in defining relative path in jsp pages.

I include the pages using following code.



On my system using eclispe and tomcat 5.5 it is running fine and it is fetching the page.

But when i try to run it on server I mean server of some web hosting copnay I am getting the following error. I tried to correct it but it seems like that The web hosting server dont know the ../.. format.

the error log which i m getting is



My file structure is

WebContent-->tiles
--->pages-->JUnit---> .jsp files
Please help.
[ December 12, 2008: Message edited by: Himanshu Gupta ]

My Blog SCJP 5 SCWCD 5
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Can someone please help me in this context.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823

I do not have much idea but the error says that the container cannot find the path you have specified.
Which is the context root of your application?


Regards, Sud.
SCJP 5 ScjpFAQ JLS
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

I think they have disabled ../.. because of security constraints as if they allow any one can write code to go to its parent directories and can get the details and can delete them or modify them if they have permission. But truly speaking I don't know what the actual thing is?

My pages are in different folders now to bypass this error I can put them all under web-inf but then it will become very hard to manage them.

Do we have some better options?
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Originally posted by Sudipto Shekhar:
I do not have much idea but the error says that the container cannot find the path you have specified.
Which is the context root of your application?


The application is running fine in my system. The problem is coming that when the hosting machine sees ../.. it is not going to parent of parent directory. It is trying to use it as complete URL. You may see the error log.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823

Have you tried using tag files?
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Not yet. I dont know any specific reason to use tag files as whatever I use I do have to provide the full path to the root folder.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823




Using standard actions and not directive.
And place the .tag file accordingly in the directory structure.


Hope this helps.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61190
    
  66

Do not ever use page-relative addressing in JSPs. As you have seen, they are fragile and unreliable.

Use server-relative addressing as described in the JSP FAQ on resource URLs.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823

Will using the standard actions help in this condition Bear?
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Using this I am getting following error..




Error

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Using server relative URL is easy in terms of importing script files, css and images. It is also working fine in defining href of urls.

But I am not able to solve how to use it in <jsp:include> or <%@ include > .

Can someone help me.


I tried it with c import



the error being shown is




Also i dont understand that why error is shown twice? My tiles folder is in WebContent and it contains the file footer.jsp .
[ December 12, 2008: Message edited by: Himanshu Gupta ]
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 823

Originally posted by Himanshu Gupta:

But I am not able to solve how to use it in <jsp:include> or <%@ include > .

Can someone help me.




I can try.

Can you post your header.jsp code?

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61190
    
  66

You have to use valid syntax. Please see the JSP FAQ entry for explicit examples.
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Can't we use <c:import> to import some page. I am always getting page not found error. Can someone help me that why this error is coming? The file is in the folder tiles which is located in WebContent.

Error log:




Even with the jsp:include I am getting same error.



Error Log:




But when I try this



It is working fine on my system but on webserver(Hosting server) It is not fetching the page and also not showing any error. Only contents are coming with no headers and footers.

I am not able to find that whats the problem? Can someone help me ?
[ December 15, 2008: Message edited by: Himanshu Gupta ]
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

To add one more information that when i am viewed the page having following content




Then i am not getting anything. Its all blank.
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

Thanks everyone. The problem got solved as it was context path issue. When I was putting everything in the root folder it was not taking any context path. I made a folder and named it as project name and pasted all the project files there. It is working fine.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in relative path in jsp page