搜索框所在的jsp文件
<form name="form_serach" method="post" action="a_search_test.jsp">
<p>
<label for="username">bookname</label>
<input type="text" name="serach_text" id="serach_text">
<input type="submit" name="serach_button" id="serach_button" value="serach">
</p>
</form>
响应文件所在的jsp文件
<%
request.setCharacterEncoding("GBK");
String search_name=request.getParameter("serach_text");
%>
<%
String sql="select price,name from new_book_Table_1 where name like ‘%" + search_name + "%‘";
%>
最后要注意编码问题
原文:http://blog.csdn.net/tuntunwang/article/details/22506005