• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Iframe content from Servlet Page is not Displayed

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my servlet page I call one xml response from third party server and make write it in file using filewriter and store it in local,after that


using this code i goes to test.jsp page ,in that test.jsp file ,i place iframe tag like <iframe src="file:///D:/sample/result.xml" /> but it does not show the content what can i do please provide solution
 
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iframe loading from a local directory is restricted in most of the modern browsers. It is a security feature which you must toggle off to view the contents.

You can use relative path instead.

My suggestion would be to get rid of that iframe if you are developing a modern web app and explore latest ways of dynamic content loading.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please detaily explain about dynamic content loading,with some examples without affect my flow that what i mention in my question and also i want to display dynamic xml content in iframe
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I were you, I would have used JQuery in my webapp to fulfill the remote loading

Here is a sample code



In place of '/remotesite/result.xml' , you can give the url of the xml hosted in the third party server.

Note: JQuery is one of the many options available.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Balagopal Kannampallil wrote:If I were you, I would have used JQuery in my webapp to fulfill the remote loading

Here is a sample code



In place of '/remotesite/result.xml' , you can give the url of the xml hosted in the third party server.

Note: JQuery is one of the many options available.







Thanks for your code its work for me,but file not loading inside div tag,because my xml file is F:/workspace/mind.xml so how can i load this file in div tag,sorry for silly question but jquery function and all working file also load inside of webcontent file in eclipse but not F:/,D:/ files
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Durga Roobini wrote:In my servlet page I call one xml response from third party server



When you are loading the xml response from a third party server, what is the need to load it from the local file?
You can write the response and store it in the local file for record purpose but can't you use the response object from the server as it is to display?
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to display the XML contents as it is with all the nodes, you can use the text function in jquery. Replace the script tag with this

 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
text file shows well,but xml file not displayed.actually what i did ,in java servlets i get xml response from third party server dynamically based on url which it is enter by end user,so that xml response simply write in file and store in local name as f:/workspace/mind.xml, after calling jsp page from servlet page, i want to display xml content from that file,so this only i am try to doing? is any other alternative way to achive this?
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Checkout this tutorial on how to access files from the local file system.

Note: I haven't tried that myself.
 
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the point of writing the XML to disk? Can't you keep the data in memory? It sounds like it would be used pretty much right away, yes?
 
Balagopal Kannampallil
Ranch Hand
Posts: 136
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Durga,

Time to rethink about your approach.
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:What is the point of writing the XML to disk? Can't you keep the data in memory? It sounds like it would be used pretty much right away, yes?



Just need get xml from servlet to JSP,sorry i cant think broadly tell me any other way to send xml from servlet to JSP(HTML)?
 
Durga Roobini
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Balagopal Kannampallil wrote:Durga,

Time to rethink about your approach.




Ya Sure I will try
 
Ulf Dittmer
Rancher
Posts: 43009
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having a servlet write a file, only for the JSP to read it, is bad. Not only because JSPs should not do any I/O, nor perform any kind of processing, but also because this is what request attributes are for. The servlet should perform all processing, and then set request attributes with the results, so that the JSP only creates the view, but not do any processing.

(I am assuming, of course, that the request gets forwarded from the servlet to the JSP. You haven't said one way or the other, so let us know if it's not the case.)
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!