通过流访问JSP并且动态添加参数
程序员文章站
2024-03-16 11:55:10
...
fileDownloadPath = http://localhost:8303/aws_file_server/print_label.jsp URL url = new URL(fileDownloadPath); URLConnection connection = url.openConnection(); connection.setDoOutput(true); PrintWriter outStream = new PrintWriter(connection.getOutputStream()); outStream.print("username=" + username);//xxxxx outStream.print("&password=" + password);//12345678 outStream.print("&xml=" + xml); //<?xml version="1.0" encoding="UTF-8" ?> <PrintLabelInfo><IdType>id_type_party</IdType> <StartPrintNumber>1</StartPrintNumber><OrderBy>name</OrderBy><EnqSeq>27099272</EnqSeq><PrintOpt>0</PrintOpt></PrintLabelInfo> outStream.print("&source=" + PrintInfo.SOURCE_WEB);//WEB outStream.print("&token=" + token);//0 outStream.print("&queue_category=" + queueCategory); // LABEL outStream.print("&agent_code=" + agentCode);//xxxxx outStream.close(); InputStream in = connection.getInputStream(); ==> jump to print_label_now.jsp上面的 InputStream in = connection.getInputStream(); ==> 跳转到新的URL中
下面的: 获取新参数值
String newUsername = request.getParameter("username"); String newPassword = request.getParameter("password"); String source = request.getParameter("source"); String token = request.getParameter("token"); String xml = request.getParameter("xml"); String queueCategory = request.getParameter("queue_category"); String agentCode = request.getParameter("agent_code"); if (agentCode == null && xml != null && !"".equals(xml)) { agentCode = getValueByAttribute(xml, "agent_code"); }
上一篇: 母牛的故事