code art

oxoxooxx發表於2011-08-08

PART ONE

=============

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("GBK");
HttpSession session = request.getSession();
String sid = session.getId();
CartMap cm = CartMap.getCartMap();
if (cm.carts.containsKey(sid)) {
Cart cart = cm.carts.get(sid);
session.setAttribute("cart", cart);
response.sendRedirect("Cart.jsp");
} else {
response.sendRedirect("shop.jsp");
}
}

PART TWO

=============

public static String readValue(String filePath, String key) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream(new FileInputStream(
filePath));
props.load(in);
String value = props.getProperty(key);
System.out.println(key + value);
return value;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23937368/viewspace-1053602/,如需轉載,請註明出處,否則將追究法律責任。

相關文章