am running the winbach commands through sevlet with help of convert doctool.
i worte the below code.but am not getting any result.
package com.nanna;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletEx extends HttpServlet {
public ServletEx() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name=(String)request.getParameter("file1");
try
{
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
int j=name.length();
String name1=name.substring(0,j-3);
if( osName.equals( "Windows XP" ) )
{
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "ConvertDoc /S"+name+" /F9 /T "+ name1+"TXT /C12";
}
else if( osName.equals( "Windows 95" ) )
{
cmd[0] = "command.com" ;
cmd[1] = "/C" ;
cmd[2] = name;
}
Runtime rt = Runtime.getRuntime();
out.println("Execing " + cmd[0] + " " + cmd[1]
+ " " + cmd[2]);
Process proc = rt.exec(cmd);
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(proc.getErrorStream(), "ERROR");
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(proc.getInputStream(), "OUTPUT");
// kick them off
errorGobbler.start();
outputGobbler.start();
// any error???
int exitVal = proc.waitFor();
out.println("ExitValue: " + exitVal);
} catch (Throwable t)
{
t.printStackTrace();
}
out.flush();
out.close();
}
private String subString(String name, String string) {
return null;
}
public void init() throws ServletException {
// Put your code here
}
}
/*
* Created on Sep 25, 2006
*
* TODO To change the template for this generated file go to
* Window - Preferences -
Java - Code Style - Code Templates
*/
package com.nanna;
import java.io.*;
public class StreamGobbler extends Thread{
InputStream is;
String type;
StreamGobbler(InputStream is, String type)
{
this.is = is;
this.type = type;
}
public void run()
{
try
{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
System.out.println(type + ">" + line);
} catch (IOException ioe)
{
ioe.printStackTrace();
}
}
}
i got this below out put but not any result
Execing cmd.exe /C ConvertDoc /SD:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\BEL.doc /F9 /T D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\BEL.TXT /C12 ExitValue: 1
is their any modifications require.giveme replay to me