如何从servlet类获取变量值到main.class?

时间:2017-12-11 12:20:22

标签: java class servlets

我在一个包 Servlet.class Main.class 中有两个类。我试图将从servlet请求获取的值传递给main方法。 这是servlet代码:

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    PrintWriter out = response.getWriter();
    response.setContentType("tesxt/plain");

    out.write(request.getParameter("code"));
    out.write("\n");
    out.write(request.getParameter("date"));

    Schedule_code sch = new Schedule_code();
    sch.setKod(request.getParameter("code"));
    out.write("\n" + "from class - " + sch.getKod());


    // out.close();

}

我想在main方法中获取代码日期值来执行某些操作

Main.class

public class GetFromService {

    public static void main(String[] args) throws Exception {

    ObjectMapper objectMapper = new ObjectMapper();
    String url1 = "http://192.168.1.9/udr/IhdMeta/ihd_rn.asmx/GetDescriptionIndexByCod?
sheduleCod="
            + schedule_cod + "&date=" + date;
    URL obj1 = new URL(url1);
    HttpURLConnection con1 = (HttpURLConnection) obj1.openConnection();
    con1.setRequestMethod("GET");
    }
}

0 个答案:

没有答案