import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;
public class uudisteForm extends HttpServlet{
static final String HEADER="
Kuulutaja";
static final String FOOTER="";
public String removeBR(String s){
if (s==null){return null;}
return s.replaceAll("
", "\n");
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
response.setContentType("text/html");
PrintWriter output=response.getWriter();
ResultSet rs=null;
int id=0;
if(request.getParameter("id")!=null){
id=Integer.parseInt(request.getParameter("id"));
}
int type=0;
if (request.getParameter("type")!=null){
type=Integer.parseInt(request.getParameter("type"));
}
output.println(HEADER);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connection=DriverManager.getConnection("jdbc:odbc:uudised","","");
Statement st=connection.createStatement();
if (id!=0){
rs=st.executeQuery("select * from messages where id=\'"+id+"\'");
if (!rs.next()){id=0;}
output.println("Teate muutmine
");
}else{
output.println("Teate lisamine
");
}
output.println("
Näita uudiseid
");
output.println("");
connection.close();
}catch(Exception e ){
output.println("VIGA
"+e.getMessage());
}
output.println(FOOTER);
}
}