1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import adi.AdiBean;
public class Controller extends HttpServlet {
public void init(ServletConfig config) throws ServletException {
ServletContext context = config.getServletContext();
AdiBean B = new AdiBean();
context.setAttribute("B", B);
try {
Class.forName("org.gjt.mm.mysql.Driver");
}
catch (ClassNotFoundException e) {
System.out.println(e.toString());
}
super.init(config);
}
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String base = "/jsp/";
String url = base + "Index.jsp";
String action = request.getParameter("action");
if (action!=null) {
if (action.equals("search"))
url = base + "Index.jsp";
else if (action.equals("browse"))
url = base + "Browser.jsp";
}
RequestDispatcher requestDispatcher = request.getRequestDispatcher(url);
requestDispatcher.forward(request, response);
}
} |
Partager