import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class MyServlet extends HttpServlet{
public void init(ServletConfig config) throws ServletException{
super.init(config);
}
public void doGet(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{
String tt=req.getParameter("Test");
res.setContentType("text/html");
BufferedReader br=new BufferedReader(new StringReader(tt));
FileWriter fw=new FileWriter("log.txt");
String temp=null;
while((temp=br.readLine())!=null){
fw.write(temp);
}
fw.close();
PrintWriter out=res.getWriter();
out.println("<html>");
out.println("<head><title>BasicServlet</head></title>");
out.println("<body>");
out.println("Your name is "+tt+"\n");
out.println("</body></html>");
out.close();
}
public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException, IOException{
String tt=req.getParameter("Test");
res.setContentType("text/html");
BufferedReader br=new BufferedReader(new StringReader(tt));
FileWriter fw=new FileWriter("log.txt");
String temp=null;
while((temp=br.readLine())!=null){
fw.write(temp);
}
fw.close();
PrintWriter out=res.getWriter();
out.println("<html>");
out.println("<head><title>BasicServlet</head></title>");
out.println("<body>");
out.println("Your post name is "+tt+"\n");
out.println("</body></tml>");
out.close();
}
public String getServerletInfo(){
return "BasicServlet Information";
}
}