问题描述
- J2EE里JSP页面如何执行java代码???
-
以下是java代码:
package servlet;import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import connect_DB.*
;public class ModifyCompany extends HttpServlet {public ModifyCompany() { super(); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String pwd=request.getParameter("pwd"); String com_name=request.getParameter("com_name"); String com_introduce=request.getParameter("com_introduce"); String found_time=request.getParameter("found_time"); String employee_number=request.getParameter("employee_number"); String company_address=request.getParameter("address"); String postcode=request.getParameter("postcode"); String contact_address=request.getParameter("contact_address"); String fax=request.getParameter("fax"); String contact_tel=request.getParameter("contact_phone"); String email=request.getParameter("email"); String website=request.getParameter("website"); String strSql="update E_UserInfo set password='"+pwd+"',company_name='"+com_name+"',company_profile='"+com_introduce+"',found_time='"+found_time+"',NumberOfEmployee='"+employee_number+"',company_address='"+company_address+"',post_code='"+postcode+"',contact_address='"+contact_address+"',fax='"+fax+"',contact_tel='"+contact_tel+"',E_mail='"+email+"',website='"+website+"'"; ConnectDB cdb=new ConnectDB(); cdb.doExecute(strSql); response.sendRedirect("../company/xgqyxx.jsp"); }
}
就是有修改原有企业信息,它的JSP action是一个.jsp页面,然后在这个页面中调用上面的java,求助!
解决方案
http://www.jb51.net/article/49175.htm
解决方案二:
1.写一个servlet调用那个java类的main方法。
2.在web.xml种把那个servlet配置为
1
解决方案三:
1.写一个servlet调用那个java类的main方法。
2.在web.xml种把那个servlet配置为
〈load-on-startup〉1〈/load-on-startup〉
时间: 2025-01-02 17:09:04