You provide duplicate Information!
Construct the URL with your SERVERPATH String and
use that for URLConnection.

The way you did it, SERVERPATH should not begin
with the "http://www.xyz.com/"; part, because you
provided this information allready with serverURL.

Peter


----- Original Message -----
From: Ashok Palaniswamy <[EMAIL PROTECTED]>
Date: Tuesday, July 10, 2001 0:05 am
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,
> HttpServletResponseres) 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:
> Resources: http://java.sun.com/products/servlet/external-
> resources.htmlLISTSERV 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

Reply via email to