Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将值从一个servlet传递到另一个servlet';不能使用android应用程序_Android_Servlets - Fatal编程技术网

将值从一个servlet传递到另一个servlet';不能使用android应用程序

将值从一个servlet传递到另一个servlet';不能使用android应用程序,android,servlets,Android,Servlets,我的应用程序中有两个servlet。第一个servlet包含一个post方法,第二个servlet包含一个get方法。第一个servlet将用户名传递给第二个servlet。我正在使用httpsession传递对象。当我从我电脑上的邮递员应用程序中调用时,一切正常,但当我从android应用程序调用时,它显示空对象 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws Servl

我的应用程序中有两个servlet。第一个servlet包含一个
post
方法,第二个servlet包含一个
get
方法。第一个servlet将用户名传递给第二个servlet。我正在使用
httpsession
传递对象。当我从我电脑上的邮递员应用程序中调用时,一切正常,但当我从android应用程序调用时,它显示空对象

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    GetUserTran cp = new GetUserTran();
    //cp.setBoId((String)request.getAttribute("boId"));
    HttpSession session = request.getSession();
    String urname = (String) session.getAttribute("userId");
    System.out.println(urname);
这是我的密码: 第一个servlet:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    String userName,password;
    userName=request.getParameter("userName").toString();
    password=request.getParameter("password").toString
    HttpSession session = request.getSession();
            session.setAttribute("userId",userName);
            RequestDispatcher rd=request.getRequestDispatcher("/another servlet");
            rd.forward(request,response);
            }
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    GetUserTran cp = new GetUserTran();
    //cp.setBoId((String)request.getAttribute("boId"));
    HttpSession session = request.getSession();
    String urname = (String) session.getAttribute("userId");
    System.out.println(urname);
第二个Servlet:

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    GetUserTran cp = new GetUserTran();
    //cp.setBoId((String)request.getAttribute("boId"));
    HttpSession session = request.getSession();
    String urname = (String) session.getAttribute("userId");
    System.out.println(urname);

}

请发布一些带有解释的代码。我已经添加了一个代码,发布了相关的android代码和LogCat?请发布一些带有解释的代码。我已经添加了一个代码,发布了相关的android代码和LogCat?
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    GetUserTran cp = new GetUserTran();
    //cp.setBoId((String)request.getAttribute("boId"));
    HttpSession session = request.getSession();
    String urname = (String) session.getAttribute("userId");
    System.out.println(urname);