Solved

how to write include in new file in server

Posted on 2003-11-18
3
348 Views
Last Modified: 2013-11-18
hello all,

how can i write an include file in my page..???
the script is like this

String mycode ="<%@ include file= ../../../usr/local/tomcat4/webapps/myfolder/myfile.jsp%>";

File aFile = new File(dir,"index.php");
FileWriter fw=new FileWriter(aFile);
PrintWriter pw=new PrintWriter(fw);

pw.print(mycode);
pw.close();


when i open file index.php it will call include file myfile.jsp.
right now i've got errors on the mycode.
how can i resolve it??
0
Comment
Question by:eg4
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
vk33 earned 50 total points
ID: 9777402
no, no... "include" is a directive to the JSP-processing engine. It puts the contents of the specified file instead. And you cannot insert a JSP-directive into your java-code. This is ok:
<%@ include file= ../../../usr/local/tomcat4/webapps/myfolder/myfile.jsp%>
<%
   // your code here
%>

To read the contents of a file do the following:

StringBuffer mycode = new StringBuffer();
BufferedReader fi = new BufferedReader(new FileReader("/usr/local/tomcat4/webapps/myfolder/myfile.jsp"));
String tmp = null;
while ((tmp = fi.readLine()) != null)
   mycode.append(tmp);
fi.close();
File aFile = new File(dir,"index.php");
FileWriter fw=new FileWriter(aFile);
PrintWriter pw=new PrintWriter(fw);

pw.print(mycode.toString());
pw.close();

Good luck!
0
 

Author Comment

by:eg4
ID: 9784145
thanx vk33.
I'm really appreciated your help. the code went perfect for my application.
thanx once again...:)
u deserve the points!!!
0
 
LVL 4

Expert Comment

by:vk33
ID: 9785329
Always welcome! ;)
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
What is the normal amount of queries 5 78
CSS HELP 6 88
Coldfusion- Create and save form elements in Database 7 73
Element alignment and word wrapping 9 68
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question