Hi Friends,
I have problem with servlet communication in my two servlet.My 1st servlet
taking out the xml file from database and writes that file it is working
perfectly.My 2nd servlet converts that xml file into .lit file.But this
servlet not converting my xml file.In this servlet lit1.bat file is ok
because i tried that batch file in dos prompt and also tried alone in
servlet it succefully creating .lit file.But when I communicate that file
with my 1st servlet it is not working.Please guide me where I am doing a
mistake.Any help will be highly appreciated.
Here is my codes:-
It is my 1st servlet:-
---------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
public class database extends HttpServlet
{
Connection con=null;
String queery =null;
ResultSet rs=null;
Statement stmt=null;
String s;
public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException
{
PrintWriter out = res.getWriter();
res.setContentType("text/xml");
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(Exception e)
{
System.out.println("Error from Driver:" + e.toString());
}
try
{
con=DriverManager.getConnection("jdbc:odbc:biku2","sa","");
}
catch(Exception e)
{
System.out.println("Error from DriverManager:" + e.toString());
}
try
{
stmt=con.createStatement();
}
catch(Exception e)
{
System.out.println("Error from Statement:" + e.toString());
}
try
{
queery="select x_xml from TABLE2";
}
catch(Exception e)
{
System.out.println("Error from sqlStatement:" + e.toString());
}
try
{
rs=stmt.executeQuery(queery);
}
catch(Exception e)
{
System.out.println("Error from Excecution:" + e.toString());
}
try{
while(rs.next())
{
s=rs.getString("x_xml");
FileWriter f1=new FileWriter("d:\\kdkbackup\\edrive\\Backup\\lit\\z.xml");
f1.write(s);
f1.close();
}
}catch(Exception e){}
}
}
It is my 2nd servlet:-
---------------------
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class database1 extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("application/lit");
PrintWriter out=res.getWriter();
URL url = new URL("http://127.0.0.1:7001/Start5");
URLConnection Connection = url.openConnection();
BufferedReader b = new BufferedReader(new InputStreamReader
(Connection.getInputStream()));
String line1 = b.readLine();
while((line1=b.readLine()) !=null)
{
FileWriter f1=new FileWriter("d:\\kdkbackup\\edrive\\Backup\\lit\\z.xml");
f1.write(line1);
f1.close();
}
Runtime r = Runtime.getRuntime();
Process p=null;
try
{
p=r.exec("c:\\lit1.bat");
}
catch(Exception e)
{
out.println("Error from execution" + e.toString());
}
}
}
Thanks in Advance
Bikash