url is :
http://localhost:8000/Serclet/test?name=qq&pwd=123
servlet Lane is written like this:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String name=request.getParameter("name");
String pwd=request.getParameter("pwd");
System.out.println("发送的内容:"+name+"#"+pwd);
request.getSession().setAttribute("name", name);
request.getSession().setAttribute("pwd", pwd);
response.sendRedirect("MyJsp.jsp");
out.flush();
out.close();
}
Now I want to get the servlet by calling the url return value , how does the servlet, how to write code that can only be obtained in the following return values it ? Seek expert advice below:
I call the following code:
public static void main(String[] args) {
URL url=null;
BufferedReader budr=null;
try {
url=new URL("http://localhost:8000/Serclet/test?name=qq&pwd=123");
budr=new BufferedReader(new InputStreamReader(url.openStream()));
System.out.println("qqqqqq");
System.out.println(budr.readLine());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
------ Solution ------------------------------------- -------
the budr contents all out to see them .
really have not seen anything like this to invoke the servlet
------ Solution - -------------------------------------------
doGet How to return value ah ?
------ Solution ---------------------------------------- ----
so you can do , servlet attached to the web environment , directly resolve an url, seemingly not right
------ Solution --------------- -----------------------------
amount you should only call this page something caught MyJsp.jsp ; session inside the value should not catch it I think
------ Solution -------------------------- ------------------
public void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType ("text / html");
PrintWriter out = response.getWriter ();
String name = request.getParameter ("name");
String pwd = request.getParameter ("pwd");
out.write ("xxxxxxxx");
out.flush ();
out.close ();
}
------ For reference only ------------------------- --------------
budr is to call the url address , and this is the url address pointing servlet. budr where only write so much. servlet, you can not pass values to the jsp page do ? I am now thinking I only call this url via budr Can you get the servlet value. servlet inside how to write it ?
------ For reference only -------------------------------------- -
I am now going to ask how to write in a servlet url can only be obtained by calling the servlet value. As I entered directly in the browser http://localhost:8000/Serclet/test?name=qq&pwd=123, you can get a value.
------ For reference only -------------------------------------- -
session that how we can get the value of it ? I have seen http://ipyy.net/WS/UpdPwd.aspx?CorpID = * & Pwd = * & NewPwd = * this message interface , direct mass participation can be further page to get a return value. Url can also be obtained by calling the return value. I am now the url does not just tell him the same kind of interface do ? How do I write a servlet can as he did in the browser, the return value can be entered , the call can also get the return value?
------ For reference only -------------------------------------- -
MyJsp.jsp inside the session in which the value of the output to inputStream inside out and then grab did not know this right
------ For reference only ------- --------------------------------
I am now going to ask how to write in a servlet url can only be obtained by calling the servlet value. As I entered directly in the browser http://localhost:8000/Serclet/test?name=qq&pwd=123, you can get a value.
url = new URL ("http://localhost:8000/Serclet/test?name=qq&pwd=123");
url where you have the name and pwd values , the interception would not it ?
------ For reference only -------------------------------------- -
may be possible , do not put value on the request inside
directly PrintWriter output
------ For reference only ----------------------------- ----------
PrintWriter how to write it ? I need to write jsp pages do ? If necessary , PrintWriter is written in the servlet or jsp pages in it ? PrintWriter output is how to write it ? Thank you advice !
------ For reference only ---------------------------------------
url to access the servlet servlet reads inside , the same as ajax submit returns does not point to the page directly return text data ;
------ For reference only -------------------- -------------------
Thank you, has been written out ! Thank you very much !
------ For reference only ---------------------------------------
I am now ask how to write in a servlet url can only be obtained by calling the servlet value. As I entered directly in the browser http://localhost:8000/Serclet/test?name=qq&pwd=123, you can get a value.
url = new URL ("http://localhost:8000/Serclet/test?name=qq&pwd=123");
url where you have the name and pwd values , the interception would not it ?
interception I will , but my main purpose is to get the servlet to call url value . Is not necessarily the name or pwd; thank you for your help !
------ For reference only ---------------------------------------
may be noted that the time to write down encoding format , Chinese garbled likely
------ For reference only ---------------------------------------
Thank you help, I've followed gb19861012 said the way to write out !
------ For reference only ---------------------------------------
Thank you help !
------ For reference only ---------------------------------------
Blessings, Thank you !
------ For reference only ---------------------------------------
be useful for me , ha ha,
没有评论:
发表评论