Java japplet到servlet通信,未到达servlet
我试图将post数据从japplet发送到servlet“Connexion”,但我放在servlet init方法和processRequest方法中的输出永远不会显示在控制台中 这是我的japplet中的send方法调用Java japplet到servlet通信,未到达servlet,java,servlets,jakarta-ee,applet,japplet,Java,Servlets,Jakarta Ee,Applet,Japplet,我试图将post数据从japplet发送到servlet“Connexion”,但我放在servlet init方法和processRequest方法中的输出永远不会显示在控制台中 这是我的japplet中的send方法调用 private void jButtonEntrerActionPerformed(java.awt.event.ActionEvent evt) { try {
private void jButtonEntrerActionPerformed(java.awt.event.ActionEvent evt) {
try {
String infos = "login=" + URLEncoder.encode(FieldLogin.getText(), "UTF-8")
+ "&mdp=" + URLEncoder.encode(FieldMdp.getText(), "UTF-8")+"&action=Login";
//"http://localhost:8088/Web_Applic_Achats_2/Connexion"
SendPost("/Connexion", infos, getCodeBase());
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Register.class.getName()).log(Level.SEVERE, null, ex);
}
}
sendPost方法定义(在抽象类Send中)
最后是我的servlet连接
public class Connexion extends HttpServlet{
BeanBDAccess bdAccess= null;
ServletContext sc;
@Override
public void init() throws ServletException {
System.out.println("Hey init");
try {
bdAccess= new BeanBDAccessMysql("BD_SOCIETE", "root", "boulaite");
} catch (Exception ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
}
sc = getServletContext();
}
@Override
public void destroy() {
if(bdAccess != null)
{
try {
bdAccess.FermerConnectionBd();
} catch (Exception ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
System.out.println("Hey processRequest");
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
// .... code ....
}
}
编辑
我运行了许多测试,发现http服务器监视器(netbeans)中没有我的参数或完整的请求uri。
但是当我在applet中输出url时,url是正常的
上次编辑:
我不知道它是否会改变什么,但我在http服务器监视器中注意到,我得到了一个304 status:exit未修改
什么是processRequest()方法,您希望如何调用它?将此设置为doPost()。doGet()和doPost()调用processRequest(),它们由netbeans在创建servlet时生成
public class Connexion extends HttpServlet{
BeanBDAccess bdAccess= null;
ServletContext sc;
@Override
public void init() throws ServletException {
System.out.println("Hey init");
try {
bdAccess= new BeanBDAccessMysql("BD_SOCIETE", "root", "boulaite");
} catch (Exception ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
}
sc = getServletContext();
}
@Override
public void destroy() {
if(bdAccess != null)
{
try {
bdAccess.FermerConnectionBd();
} catch (Exception ex) {
Logger.getLogger(Connexion.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
System.out.println("Hey processRequest");
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
// .... code ....
}
}