Hi lakshmi,
U assume the above file as "xmldb.jsp"..
Now write 1 more jsp called "xmlwrite.jsp",which processes the output from xmldb.jsp through URL object and creates the file..Here is my sample code for xmlwrite.jsp
driver=request.getParameter("driver");
url=request.getParameter("url");
user=request.getParameter("user");
pwd=request.getParameter("pwd");
table=request.getParameter("table");
try
{
sql="select * from "+table;
sql=sql.replace(' ','+');
String fileloc="../webapps/ROOT/xml/"+table+".xml";
FileOutputStream file=new FileOutputStream(fileloc);
String pp="http://localhost:8080/xmlshop/xmldb.jsp?driver="+driver+"&url="+url+"&user="+user+"&pwd="+pwd+"&sql="+sql;
URL urlstr=new URL(pp);
BufferedReader buf=new BufferedReader(new InputStreamReader(urlstr.openStream()));
String in;
while ((in = buf.readLine()) != null)
{
byte[] b=in.getBytes();
file.write(b);
}
out.println("File created Successfully");
buf.close();
file.close();
}
catch(Exception e)
{
out.println("Error :"+ e);
}
%>
I am calling this xmlwrite.jsp from a html file,which gets five inputs from the user namely driver name,database url,user name,password and table name. This xmlwrite.jsp again calls xmldb.jsp via URL and gets back the xml document.After that the xmlwrite.jsp writes the document in a file..
suppose u enter the table name as customer then your file will be stored as ../webapps/ROOT/xml/customer.xml. in the
tomcat application server..
Oops!..Confused?..If you go thru both the codes again then u will understand..
Best Regards,
Paramaguru.