Sending XML to Servlet from Action Script

Posted by John Doe on Stack Overflow See other posts from Stack Overflow or by John Doe
Published on 2010-04-29T14:32:40Z Indexed on 2010/04/29 14:47 UTC
Read the original article Hit count: 225

Filed under:
|
|

I am only getting empty arrays on output. Anyone know what Exactly I'm doing wrong?

   package myDungeonAccessor;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class myDungeonAccessorServlet extends HttpServlet {
private myDungeonAccessor dataAccessor;

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
        /* TODO output your page here
        out.println("<html>");
        out.println("<head>");
        out.println("<title>Servlet myDungeonAccessorServlet</title>");
        out.println("</head>");
        out.println("<body>");
        out.println("<h1>Servlet myDungeonAccessorServlet at " + request.getContextPath () + "</h1>");
        out.println("</body>");
        out.println("</html>");
         */
    } finally {
        out.close();
    }
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** 
 * Handles the HTTP <code>GET</code> method.
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    processRequest(request, response);
    // PrintWriter out = response.getWriter();
    System.out.println("yo mom");


}

/** 
 * Handles the HTTP <code>POST</code> method.
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    //System.out.println("heppo");
    //dataAccessor = new myDungeonAccessor();
   System.out.println("Hello");

   try {

    System.out.println("HEADERS: " + request.getHeaderNames());
    ObjectInputStream in = new ObjectInputStream(request.getInputStream());
    ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
   } catch(Exception e) {
       e.printStackTrace();
   }

    System.out.println("WAZZUP");

    byte [] buffer = new byte[4096];

    //in.read(buffer);

    System.out.println("TEST!");

    String s = new String(buffer);

    System.out.println("Update S:" + s);



}

/** 
 * Returns a short description of the servlet.
 * @return a String containing servlet description
 */
@Override
public String getServletInfo() {
    return "Short description";
}

}

© Stack Overflow or respective owner

Related posts about Xml

Related posts about actionscript-3