Solved

how to write include in new file in server

Posted on 2003-11-18
3
349 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Getting attribute Values using xslt 4 61
replace quotes with UTF-8 character 38 112
how to add new optional parameter to JSP 1 55
How to build a web site 17 59
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

726 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