×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

Please come in....

URLConnection has a method #setRequestProperty(?, ?). You can use it to send the parameter from Java Application(Client) to the Servlet(Server). I suggest you look into the examples in Java Servlets by Karl Moss (it is a red cover book, published by mcGraw Hill). See pages 93--99. You can find the book in most bookstore. For the example code, you can download it from www.servletguru.com. I do believe I have helped you because you do not use the browser as the client. So you need to work at a lower level than doGet and doPost. Good luck, my pal.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 请教一个JAVA问题,如何在URLconnection 里设置象HTML PAGE里的<input type="text" name="search">的参数使得在SERVLET里的HttpRequest.getParameter("search")能取到.
    • 应该可以, 我试过用GET, 参数直接在URL中 也可以
      • GET给人感觉不安全太容易被人看见。
        • use encode
      • 忘了说了我想要的是在doPost()里实现。
        • Use encoding should be okey
    • like this: http://www.rolia.com/?rpp=20
    • Use URLEncoder.encode()
    • If you can specify your scenario, maybe I can give you some hints.
      • I am writing an authentication servlet. The servlet will parse the username/password passed from a GUI client.We are not using SSL currently so I wIll like to use doPost method.
        • Please come in....
          URLConnection has a method #setRequestProperty(?, ?). You can use it to send the parameter from Java Application(Client) to the Servlet(Server). I suggest you look into the examples in Java Servlets by Karl Moss (it is a red cover book, published by mcGraw Hill). See pages 93--99. You can find the book in most bookstore. For the example code, you can download it from www.servletguru.com. I do believe I have helped you because you do not use the browser as the client. So you need to work at a lower level than doGet and doPost. Good luck, my pal.
          • I have try setRequestProperty, It only set the header of HTTP request.
            • I can not retrieve the property by getheader(). I can not find the book right now.
            • Basically, you need to marshal the data here.
              Because you have lost luxuries provided by the browser, you have to send data by yourself. Trust me, if you look into the example I referred to earlier, you will soon get the solutions.
              • can you post the small piece of code here?
              • Can you put the the line of code that setRequestProperty(?,?) here? Thank you for your help!!!
                • Please download the code on your own and look into the book by Karl Moss.
                  • where is the code ?I can not find the book.
            • I can not retrieve the property by getParameter,but only by getheader(). It seem to me it not decent way either.I can not find the book right now.
              • Here you go...
                Because you don't use HTML form, or hyperlink, you cannot use request.getParameter(...). In one word, you have no browser, so you have lost somethin you have got used to. This is why I said you must marshal the data on your own.