• Post Reply Bookmark Topic Watch Topic
  • New Topic

reading a "non-context" HTML file in JSP  RSS feed

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have to read and render a HTML file which is in some file server in a JSP of my application. Basically the file is not in context of application so "include" will not work.

Following two approaches I tried and worked:



What I'd like to know is, which one is preferable? Or any other better approach.

I read in some forums that Iframe is not recommended though I don't exactly know the reason - may be because it's like a new document (DOM) all together in document, so what?

Anyway, please provide your inputs.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It has nothing to do with using an iframe or not. Using the file path for a URL will allows the application to work only on your system. Is that what you want?

The real solution is to move the file into the web app.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It has nothing to do with using an iframe or not. Using the file path for a URL will allows the application to work only on your system.


But if I don't use iframe or frame, how do I give path? In which tag?


Is that what you want?


The file will be on same system so should be okay.



The real solution is to move the file into the web app.


I can move the file into web app but what advantage I'll get out of it?

Thanks.
 
Sean Clark
Rancher
Posts: 377
Android Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But if I don't use iframe or frame, how do I give path? In which tag?


Remember that using the iframe will go to the local drive so if I was to look on your site it would look at my "c:/test.html" on my hard drive and not the server, is that what you are looking for? or is each user in the of the web application going to have their own html file that you put on their C drive?

I can move the file into web app but what advantage I'll get out of it?


It may be worth it, because you may wish to deploy on another installation server and you don't want to have to be moving lots of files about. Does the file change?

Sean

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ankur rathi wrote:I can move the file into web app but what advantage I'll get out of it?

Not having to stand on your head and whistle Dixie to get things to work.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Remember that using the iframe will go to the local drive so if I was to look on your site it would look at my "c:/test.html" on my hard drive and not the server, is that what you are looking for? or is each user in the of the web application going to have their own html file that you put on their C drive?


No. It will be server's path. For example, if I have a unix server which has folder structure something like: users/ankur/webpages/test.html

The path would be something like: //servername/users/ankur/webpages/test.html


It may be worth it, because you may wish to deploy on another installation server and you don't want to have to be moving lots of files about. Does the file change?


True. But the files are placed by another program. So changing location in that program will do the trick.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ankur rathi wrote:The path would be something like: //servername/users/ankur/webpages/test.html

Which, again, will only work on your system. Do you think my system has the //servername path mapped? Really?
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
ankur rathi wrote:The path would be something like: //servername/users/ankur/webpages/test.html

Which, again, will only work on your system. Do you think my system has the //servername path mapped? Really?


Hmmm... it should actually be a "global" path that can be accessible from any (client's) system like http://www.a.com/test.html. My bad. Sorry.
Looks like I am left with first approach only.

The reason that I am not comfortable in keeping HTML file inside my application is: 1. It's been placed by a different program. I don't think it will be a good idea to give access of my application to that program. 2. It's huge bunch of files which I don't want in my application as they don't belong here.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your approach of reading and serving the files is the most viable. Using file-system paths just won't work on any system but yours since no one else has direct access to your file system.

By the way, that explanation of why the file should remain separate is something that would have been helpful in the initial post.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!