日期:2014-05-17 浏览次数:20898 次
public class Redirect extends HttpServlet
{
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
InputStream inStream = Redirect.class.getClassLoader().getResourceAsStream("com/yulei/bank/web/userconfig.properties");
if (inStream == null)
{
request.getRequestDispatcher("/WEB-INF/jsp/init.jsp").forward(request, response);
}
else
{
Properties props = new Properties();
props.load(inStream);
ServletContext application = this.getServletContext();
application.setAttribute("bankPrefix", props.getProperty("bankPrefix"));
application.setAttribute("bankName", props.getProperty("bankName"));
request.getRequestDispatcher("/WEB-INF/jsp/login.jsp").forward(request, response);
}
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
String bankPrefix = request.getParameter("bankPrefix");
String bankName = request.getParameter("bankName");
String url = request.getParameter("url");
String username = request.getParameter("username");
String password = request.getParameter("password");
// 生成userconfig.properties
// bankPrefix=
// bankName=
Properties props = new Properties();
props.setProperty("bankPrefix", bankPrefix);
props.setProperty("bankName", bankName);
props.store(new FileOutputStream("userconfig.properties"),"init");
// 修改dbcpconfig.properties的数据库、用户名、密码
// url=jdbc:mysql://localhost:3306/test
// username=root
// password=root
request.getRequestDispatcher("/redirect").forward(request, response);
}
}