Take a look at the com.oreilly.servlet.HttpMessage class, either on
O'Reilly's website or Jason Hunter's "Java Servlet Programming, 2d. Ed.,"
pp. 316-319.
Cheers!
Mark
----- Original Message -----
From: "Ashok Palaniswamy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 6:05 PM
Subject: Invoking a servlet from an Application
> I tried on this topic in the archives.. did'nt get a good answer.
>
> I'm trying to invoke a servlet from a java Application. I'm passing url
> parameters to the servlet so that the servlet does some validations with
> the parameters. The problem with the code is, the servlet is not able to
get
> the values that are passed as the URL parameters..
>
> Here's the code.. can somebody tell me where I'm doin wrong.
>
> Client code:
> try{
> URL serverURL = new
URL("http://www.xyz.com:8080/");
> String SERVERPATH =
> "http://www.xyz.com:8080/servlet/DBServlet?login=123123123";
> URLConnection connect = (new URL(serverURL,
> SERVERPATH)).openConnection();
> connect.setDefaultUseCaches(false);
> connect.setUseCaches(false);
> connect.setDoInput(true);
> connect.setDoOutput(true);
> connect.connect();
>
> reportStatus("connected to the servlet");
> //urlConnection.doOutput(true);
> }catch(Exception urlEx){
> System.out.println("Exception: URL:
> "+urlEx.toString());
> reportStatus("Not connected to the servlet");
> }
>
> servlet code:
>
> import javax.servlet.*;
> import javax.servlet.http.*;
> import java.io.*;
>
> public class DBServlet extends HttpServlet{
>
> public void init(ServletConfig config) throws ServletException {
>
> try {
> System.out.println("URL Server..!!");
> }catch(Exception e1) {
> System.out.println("Exception: DBGatewayServlet
init
> - e1: " +e1.getMessage());
> }
> }
>
> public void doGet(HttpServletRequest req, HttpServletResponse
> res) throws IOException, ServletException {
> System.out.println("into URLServlet");
> res.setContentType("text/html");
> PrintWriter pw = res.getWriter();
> System.out.println("LoginName:
"+req.getParameter("login"));
>
> }
> }
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html