java Servlet中转换成json运行报错了,求助

错误: 代理抛出异常错误: java.rmi.server.ExportException: Port already in use: 1099; nested exception is:
java.net.BindException: Address already in use (Bind failed)
具体代码如下:

@Override
protected  void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException,IOException {
    response.setCharacterEncoding("UTF-8");
    response.setContentType("application/json; charset=utf-8");
    String jsonStr= null;
    try {
        jsonStr = this.jsonString();
    } catch (JSONException e) {
        e.printStackTrace();
    }

    //array.toString()
    PrintWriter out = null;
    try {
        out = response.getWriter();
        out.write(jsonStr);
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (out != null) {
            out.close();
        }
    }
}

String jsonString() throws JSONException{
JSONObject json = null;
json = new JSONObject();
json.put("username", "wanglihong");
json.put("height", "12.5");
json.put("age", 24);

 String jsonStr= json.toString();
 return jsonStr;

}

你的1099端口被占用了,然后现在你需要使用1099端口所以就报错了
处理方法:
https://jingyan.baidu.com/article/215817f784c2d61eda1423c4.html

报的这个错与你贴出的代码没有关系,,是端口不可用的问题!!!!

是端口占用的问题,用命令把进程杀掉,重启启动tomcat即可。

http://www.cnblogs.com/liuyanxia/p/6755520.html