Java cross-domain access problem logging

Source: Internet
Author: User

Cross-domain Access records

Package com.alphasta.zsbs.servlet;

Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.OutputStream;
Import Java.io.PrintWriter;
Import Java.net.URLDecoder;
Import Java.util.Map;

Import javax.servlet.ServletException;
Import Javax.servlet.http.HttpServlet;
Import Javax.servlet.http.HttpServletRequest;
Import Javax.servlet.http.HttpServletResponse;

Import Net.sf.json.JSONArray;
Import Net.sf.json.JSONObject;

Import Org.apache.commons.lang.StringUtils;
Import Org.apache.log4j.Logger;

Import com.alphasta.zsbs.util.Resources;
Import Com.google.gson.JsonArray;
Import Com.google.gson.JsonObject;
Import Com.google.gson.JsonParser;
Import COM.YX.FRAME.JDBC.SQL;
Import Com.yx.frame.jdbc.SqlEntry;
Import com.yx.frame.jdbc.Table;
/**
* Update user Information
* @author D
*
*/
public class Updateuserinfoservlet extends HttpServlet {

Private Logger log = Logger.getlogger (Updateuserinfoservlet.class);
/**
*
*/
Private static final long serialversionuid = 3869311915733581508L;

/**
* Constructor of the object.
*/
Public Updateuserinfoservlet () {
Super ();
}

/**
* Destruction of the servlet. <br>
*/
public void Destroy () {
Super.destroy (); Just puts "destroy" string in log
}

/**
* The Doget method of the servlet. <br>
*
* This method was called when a form had its tag value method equals to get.
*
* @param request
* The request send by the client to the server
* @param response
* The response send by the server to the client
* @throws servletexception
* If an error occurred
* @throws IOException
* If an error occurred
*/
public void doget (HttpServletRequest request, httpservletresponse response)
Throws Servletexception, IOException {

Response.setcontenttype ("text/html; Charset=utf-8 ");
PrintWriter out = Response.getwriter ();
OUT.PRINTLN ("Get Request not supported");
Out.flush ();
Out.close ();
}

/**
* The DoPost method of the servlet. <br>
*
* This method was called when a form have its tag value Method equals to
* post.
*
* @param request
* The request for send by the client to the server
* @param Response
* The response send by the server to the client
* @throws servletexception
* If an error occurred
* @throws IOException
* If an error occurred
*/
public void DoPost (HttpServletRequest request, HTTPSERVLETRESP Onse response)
throws Servletexception, IOException {
Response.setheader ("Access-control-allow-credentials", "true");//Intermediate test process has been a problem, add this is good
Response.setheader ("Access-control-allow-headers", "origin, X-csrftoken, Content-type, Accept, X-auth-code, X-app-id, X-token ");
Response.setheader ("Access-control-allow-method", "POST, GET, OPTIONS");
Response.setheader ("Access-control-allow-origin", "Http://XXXX");//Note add your own address
Response.setcontenttype (" Application/json; Charset=utf-8 ");



String Userjson = "";

Logic Code Section


Log.info ("Update post--" +userjson);
OutputStream re_out = Response.getoutputstream ();
Re_out.write (Userjson.getbytes ("UTF-8"));
Re_out.flush ();
Log.info ("Update post Finish--" +userjson+ "-" +userjson.getbytes ("UTF-8"));
}


/**
* Initialization of the servlet. <br>
*
* @throws servletexception
* If an error occurs
*/
public void Init () throws Servletexception {
Put Your code here
}

}

Java cross-domain access problem logging

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.