Hi paresh, execute method requires an ActionForward object....I think this might help you...
Cheers<br />-------------<br />Swapnil<br /> <br />SCJP5-81%<br /> <br />"Dictionary is the only place where Success come before Work"
Joined: Feb 15, 2005
Originally posted by paresh doshi: my file is in C:\Javaranch.html
None of the techniques suggested by any of us will work unless the html file is in the context root of your application or one of its subdirectories.
If you need to display a file that is outside of the context root, you would need to use the classes in the java.io package to read the file and output it to the HTTPServletResponse object's output stream.
Joined: Nov 20, 2006
Thanks for your reply. I have tried in similar manner using File objects. I have used the following code.
response.setContentType("text/html"); File f = new File ( "C:\\jboss-4.0.3SP1\server\\default","Javaranch.html"); FileInputStream fis = new FileInputStream(f); byte btData = new byte[(int)f.length()]; int iBytesRead = fis.read(btData); System.out.println("Before Creating OutputStream"); ServletOutputStream out = response.getOutputStream(); DataOutputStream out = new DataOutputStream( res.getOutputStream() ); System.out.println("Before Writing OutputStream"); out.write( btData);
This code is rendering the html file, but the images are not loaded.
Can you help me out in that... or is there any other way to render html file(lying in JBOSS_HOME location or any absolute path) using struts action.
Joined: Feb 15, 2005
First of all, is there a reason these files have to be outside the context root? It would be so much simpler to deal with them if you could just move them inside the context root.
You run into the same problem with image files outside the web context root as you do with html files. You will have to create an Action class that will read an image file and output it to the HTTPServletResponse object's output stream.
Then in your HTML file, you will have to reference the Action class you created in your <img> tag. Example: