Hi all Friends,
I have problem with servlet communication.I have three
servlet My 1st servlet converts xml file to html file
for this Iam using saxon for converting through
Runtime class.And my 2nd servlet converting that html
file to .rb(rocket edition)and third servlet starts
downloading of that .rb file for that iam using
jspsmartupload package.My problem is that my first
servlet creating .html file but the size of the file
is zero byte.And 2nd servlet also converting that html
file to .rb file and 3rd servlet also starts
downloading. But in downloaded file there is no
content.Please tell me where I done a mistake.Is it
the right way using res.sendRedirect() for servlet
communication.If it is not Please tell me what is the
best method fot that.Can u give me the code for that.
Here is my codes:-
It is my 1st servlet:-
-----------------------import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class chain1 extends HttpServlet
{
public void doGet(HttpServletRequest
req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
Runtime r = Runtime.getRuntime();
Process p=null;
try
{
p=r.exec("c:\\saxon.bat");
}
catch(Exception e)
{
out.println("Error from execution" +
e.toString());
}
res.sendRedirect("http://127.0.0.1:7001/Start");
}
}
It is my 2nd servlet:-
---------------------
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class chain2 extends HttpServlet
{
public void doGet(HttpServletRequest
req,HttpServletResponse res)
throws ServletException,IOException
{
res.setContentType("text/rb");
PrintWriter out=res.getWriter();
BufferedReader b = new BufferedReader(
new InputStreamReader(req.getInputStream()));
String line1 = b.readLine();
FileWriter f1=new
FileWriter("c:\\checkw.html");
while((line1=b.readLine()) !=null)
{
f1.write(line1);
}
f1.close();
Runtime r = Runtime.getRuntime();
Process p=null;
try
{
p=r.exec("c:\\rbmake\\rbmake -o test8
c:\\checkw.html");
BufferedReader in = new BufferedReader(new
InputStreamReader(p.getInputStream()));
String line=null;
while((line=in.readLine()) !=null)
{
out.println(line);
}
}
catch(Exception e)
{
out.println("Error from execution" +
e.toString());
}
res.sendRedirect("http://127.0.0.1:7001/Start2");
}
}
It is my 3rd servlet:-
------------------------
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Vector;
import com.jspsmart.upload.*;
public class final1 extends HttpServlet {
private ServletConfig config;
final public void init(ServletConfig config) throws
ServletException {
this.config = config;
}
final public ServletConfig getServletConfig() {
return config;
}
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
{
BufferedReader b = new
BufferedReader( new
InputStreamReader(request.getInputStream()));
String line1 = b.readLine();
while((line1=b.readLine())
!=null)
{
FileWriter f1=new
FileWriter("c:\\bea\\wlserver6.0sp1\\test8.rb");
f1.write(line1);
f1.close();
}
SmartUpload mySmartUpload = new SmartUpload();
try {
mySmartUpload.initialize(config,request,response);
}
catch(Exception e)
{
System.out.println("Error"+e.toString());
}
try
{
mySmartUpload.downloadFile("c:\\bea\\wlserver6.0sp1\\test8.rb","text/rb",".rb");
}
catch(Exception e)
{
System.out.println("Error"+e.toString());
}
}
}
Thanks in Advance
Bikash
__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html