wood burning stoves 2.0*
The moose likes Servlets and the fly likes How can i passed parameter to flatfile(written in c++)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How can i passed parameter to flatfile(written in c++)?" Watch "How can i passed parameter to flatfile(written in c++)?" New topic
Author

How can i passed parameter to flatfile(written in c++)?

sameer ingle
Greenhorn

Joined: May 10, 2001
Posts: 2
how can i passed parameter to flatfile(written in c++),Fasta search Engine?
code:///
////////
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
/**
* Hello World. This servlet simply says hi.
*
* <P> This is useful for testing the servlet configuration process,
* since this servlet isn't installed.
*/
public class FastaEngine extends HttpServlet {
public void doPost (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException
{
PrintWriter out;

res.setContentType("text/html");
out = res.getWriter();

String source=req.getParameter("S1");
String v =req.getParameter("libpo");
String databasename =req.getParameter("program");
//String v =req.getParameterValues("libpo");
out.println("<b>Getting the value from text box</b>");
out.println("<H1>"+v+"</H1>");
out.println("<H1>"+databasename+"</H1>");
//building string From various Option
//String command="D:/jithesh/sameer/"+databasename+" - "+ v+" ecoli3.txt ecoli3.txt";
String command="D:/jithesh/sameer/fasta -Q -O output d:/javaproject/ecoli3.txt d:/javaproject/mito.nt";
//D:\\jithesh\\sameer\\Fasta -q -o output salmo.txt swissport
out.println(command);
Date dd1=new Date(System.currentTimeMillis()-24*60*60*1000);
out.println("Time Started:"+dd1);
GregorianCalendar gc1 = new GregorianCalendar();
Date d1 = gc1.getTime();
long l1 = d1.getTime();
/* TAKING QUERY STRING FROM THE TEXT BOX AND WRITING TO THE FILE
OF NAME DEMO.TXT
CODE BEGAIN
*/
char buffer[]=new char[source.length()];
source.getChars(0,source.length(),buffer,0);
//FileReader fr =new FileReader("d:/javaproject/ShowFile.java");
FileWriter wr =new FileWriter("c:/demo2.txt");
for(int i=0;i<buffer.length;i++){
wr.write(buffer[i]);
}
wr.close();
//CODE OF FILE WRITING END.

String s="ASDFSDFDASF";
out.println("<html>");
out.println("<body bgcolor="+"#DBEDFF"+">");
out.println("<p>");
out.println("<hr noshade color="+"#FF0000"+">");
out.println("<H1>Readding The .Exe FileContent......</H1>");
out.println("</body></html>");

//Executing The File And Reading the File
//get Runtime it return the proccess
Runtime rt=Runtime.getRuntime();
//executing the exe file.
//Process pro=rt.exec("D:/jithesh/sameer/Fasta -o ecoli3.txt ecoli3.txt");
Process pro=rt.exec(command);
//reading the file content in byte stream
out.println("Executed");

InputStreamReader isr=new InputStreamReader(pro.getInputStream());
//Storing in the bufferreader.
BufferedReader br= new BufferedReader(isr);
String line;
//Reading the output Content...
while((line=br.readLine())!=null)
// out.println("<br>"+line+"</br>");
out.println("<font color=red><font size="+"1"+">"+"<br>"+line+"</font></br></font>");
GregorianCalendar gc2 = new GregorianCalendar();
Date d2 = gc2.getTime();
long l2 = d2.getTime();
long difference = l2 - l1;
out.println("Elapsed milliseconds: " + difference);

out.println("<html>");
out.println("<body bgcolor="+"#CCCCFF"+">");
out.println("<p>");
out.println("<hr noshade color="+"#FF0000"+">");

out.println("<b>"+"Hello World sameer ....."+source+"</b>");
out.println("<p><a href="+"http://localhost:8080/servlet/FastaOutput"+">see Result of Fasta Engine.....</a></p>");
out.println("</body></html>");
// res.sendRedirect("http://localhost:8080/servlet/RedirectServlet");
Date dd2=new Date(System.currentTimeMillis()-24*60*60*1000);
out.println("<br>TimeComPleted"+dd2+"</br>");
out.println("<br>Elapsed milliseconds: " + difference+"<br>");
}
}
Mark Simms
Ranch Hand

Joined: Jul 20, 2000
Posts: 36
the servlet will need an Init() and a doPost() doGet() set of methods.
Just pick-up the parameter :
String value_to_pass = req.getParameter("xyz");
in the doPost method

Mark
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i passed parameter to flatfile(written in c++)?
 
Similar Threads
How to disable cookies
Date diff function in java
sequence of form information is not the same WHY???
Problem with session.invalidate()
Tell me about exec(),biojava...,how to connect database written in c executable file?