Calling Servlet from Java-Class

Hi,
I have a normal java-class that is working with request/response Objects. From within this class I want to call a local servlet, let it do some work with the request and the response and then return it to the class.
I guess the RequestDispatcher can only be called from within a Servlet, but my class is not a servlet.
The getServlet()-method is not working any more.
Maybe somebody has an idea.
Thanks a lot,
Matthias

Hi,
I have a normal java-class that is working with
request/response Objects. From within this class I
want to call a local servlet, let it do some work with
the request and the response and then return it to the
class.
I guess the RequestDispatcher can only be called from
within a Servlet, but my class is not a servlet.
The getServlet()-method is not working any more.
Maybe somebody has an idea.
Thanks a lot,
MatthiasThis is not very pretty, so I think you should redessign, but you can open a URLConnection from your class pointing to the URL of the servlet. As far as I know you can't invoke a servlet directly, because you can't get a reference to it, it can only be invoked by the container...

Similar Messages

  • Calling Servlet from Java Class in eclipse

    Hi ,
    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();
    I am using the above code in JAVA to Connect to Servlet I have given Print statement in Servlet such that whenever it calls it prints on Console but when I try to run the code the Statement is not printed in the Console of eclipse I think URL connection is not able to establish any connection ..... if any has solution for this please reply
    Thanks & Regards,
    Arvind

    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();Why should the Servlet running in different Runtime print on your Eclipse Runtime. Please be more clear about the question.

  • Calling servlet from java page flow

    Hi,
    I need to call servelt class from the <netui:anchor ..> tag of my jpf.
    i have mapped this servlet class in the web.xml.
    please tell us how to invoke servlet from the netui:anchor tag from the jpf action
    method.
    thanks
    shashi

    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();Why should the Servlet running in different Runtime print on your Eclipse Runtime. Please be more clear about the question.

  • Problem while calling servlet from java bean

    I am trying to call a servlet from java bean in cep.
    My java bean:
    package com.bea.wlevs.example.algotrading;
    import com.bea.wlevs.ede.api.StreamSink;
    import com.bea.wlevs.example.algotrading.event.MarketEvent;
    import javax.xml.bind.JAXBContext;
    import javax.xml.bind.Unmarshaller;
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.io.StringReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;
    public class MarketEventBean implements StreamSink {
         String s=null;
         public void onInsertEvent(Object event) {
              if (event instanceof MarketEvent) {
                   MarketEvent marketEvent = (MarketEvent) event;
                   try {
                        JAXBContext cxt = JAXBContext.newInstance(MarketEvent.class);
                        Unmarshaller unmarsh = cxt.createUnmarshaller();
                        StringReader strReader = new StringReader(marketEvent.getString_1());
                        MarketEvent obj = (MarketEvent) unmarsh.unmarshal(strReader);
                        s=obj.getSymbol();
                        System.out.println("data: " + s);
                   } catch(Exception e) {
                        e.printStackTrace();
                   try {
                        System.out.println("test1");
         URL url = new URL("http://172.18.21.94:7001/AppServletrecv-Model-context-root/ReceiveServlet");
         URLConnection conn = url.openConnection();
              System.out.println("test2");
         conn.setDoOutput(true);
              System.out.println("test3");
         BufferedWriter out =
         new BufferedWriter( new OutputStreamWriter( conn.getOutputStream() ) );
         out.write("symbol="+s);
              System.out.println("test4");
         out.flush();
         System.out.println("test5");
         out.close();
         System.out.println("test6");
         BufferedReader in =
         new BufferedReader( new InputStreamReader( conn.getInputStream() ) );
              System.out.println("test7");
         String response;
         while ( (response = in.readLine()) != null ) {
         System.out.println( response );
         in.close();
         catch ( MalformedURLException ex ) {
         // a real program would need to handle this exception
         catch ( IOException ex ) {
         // a real program would need to handle this exception
    My servlet code:
    package model;
    import javax.servlet.http.HttpServlet;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class ReceiveServlet extends HttpServlet {
    private final static String _SYMBOL = "symbol";
    public void doPost(HttpServletRequest request, HttpServletResponse response) {
    * Get the value of form parameter
    // private final static String USERNAME = "username";
    String symbol = request.getParameter( _SYMBOL );
    * Set the content type(MIME Type) of the response.
    response.setContentType("text/html");
    * Write the HTML to the response
    try {
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<head>");
    out.println("<title> A very simple servlet example</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello " + symbol +"</h1>");
    out.println("</body>");
    out.println("</html>");
    out.close();
    } catch (IOException e) {
    Web.xml:
    <?xml version = '1.0' encoding = 'windows-1252'?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">
    <servlet>
    <servlet-name>ReceiveServlet</servlet-name>
    <servlet-class>model.ReceiveServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ReceiveServlet</servlet-name>
    <url-pattern>/ReceiveServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    My servlet is running in weblogic server.
    But when I am running this program in weblogic server side there is no log.
    Edited by: 856272 on Jun 23, 2011 6:43 AM

    I would run both sides in a debugger and see what code is getting invoked

  • Calling servlet from Java

    Hello!
    I need to send XML file to servlet from Java. I generate XML in general java class.
    Is there any way how to call servlet directly from Java without using a page with form? I need to send it by post method. I need some java alternative to Microsoft.XMLHTTP object.
    Thanks

    Try this part of the Networking tutorial:
    http://java.sun.com/docs/books/tutorial/networking/urls/index.html
    It might be the answer to your question.

  • Problem accessing servlet from java class which uses Basic Authentication

    "Hi,
    I am using weblogic 6.1 server. I am calling a servlet file from a class file using HttpURLConnection. This is the code below.
              String theUsername="B1A1Z1T2";
              String thePassword="hlladmin";
              String urlString="http://rsnetserver:113/hll/servlet/CallSSRUpload";
              String userPassword = theUsername ":" thePassword;
              String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
              try
                   URL url = new URL (urlString);
                   HttpURLConnection uc=(HttpURLConnection)url.openConnection();
                   int it = 0;
                   while ((it = encoding.indexOf('\n')) != -1
                        || (it = encoding.indexOf('\r')) != -1) {
                             encoding = encoding.substring(0, it)
                             encoding.substring(it 1);
                   uc.setRequestProperty("Authorization","BASIC " encoding);
                   uc.setRequestProperty("SOAPAction", url.toString());
                   System.out.println(uc.getResponseCode());
                   System.out.println(uc.getResponseMessage());
              catch(Exception io)
                   io.printStackTrace();
                   System.out.println("error message........" io.getMessage());     
    In web.xml I have d

    Hello,
    Could you post the stack trace?
    Thanks,
    Bruce
    Vijay Babu wrote:
    >
    "Hi,
    I am using weblogic 6.1 server. I am calling a servlet file from a class file using HttpURLConnection. This is the code below.
    String theUsername="B1A1Z1T2";
    String thePassword="hlladmin";
    String urlString="http://rsnetserver:113/hll/servlet/CallSSRUpload";
    String userPassword = theUsername ":" thePassword;
    String encoding = new sun.misc.BASE64Encoder().encode (userPassword.getBytes());
    try
    URL url = new URL (urlString);
    HttpURLConnection uc=(HttpURLConnection)url.openConnection();
    int it = 0;
    while ((it = encoding.indexOf('\n')) != -1
    || (it = encoding.indexOf('\r')) != -1) {
    encoding = encoding.substring(0, it)
    encoding.substring(it 1);
    uc.setRequestProperty("Authorization","BASIC " encoding);
    uc.setRequestProperty("SOAPAction", url.toString());
    System.out.println(uc.getResponseCode());
    System.out.println(uc.getResponseMessage());
    catch(Exception io)
    io.printStackTrace();
    System.out.println("error message........" io.getMessage());
    In web.xml I have d

  • Exception while calling BPEL from Java Class

    Hi All,
    I am trying to call BPEL from my Java Code. but i am getting following exception.
    java.lang.Exception: Failed to create "ejb/collaxa/system/DomainManagerBean" bean; exception reported is: "javax.naming.NameNotFoundException: ejb/collaxa/system/DomainManagerBean not found
         at com.evermind.server.rmi.RMIClientContext.lookup(RMIClientContext.java:52)
         at javax.naming.InitialContext.lookup(InitialContext.java:351)
         at com.oracle.bpel.client.util.BeanRegistry.lookupDomainManagerBean(BeanRegistry.java:218)
         at com.oracle.bpel.client.Locator.getDomainAuth(Locator.java:975)
         at com.oracle.bpel.client.Locator.<init>(Locator.java:73)
         at callbpel.CallBPEL.main(CallBPEL.java:40)
         at com.oracle.bpel.client.util.BeanRegistry.lookupDomainManagerBean(BeanRegistry.java:232)
         at com.oracle.bpel.client.Locator.getDomainAuth(Locator.java:975)
         at com.oracle.bpel.client.Locator.<init>(Locator.java:73)
         at callbpel.CallBPEL.main(CallBPEL.java:40)
    Process exited with exit code 0.
    Following is my java code.
    package callbpel;
    import com.collaxa.cube.util.GUIDGenerator;
    import com.collaxa.xml.XMLHelper;
    import com.oracle.bpel.client.Locator;
    import com.oracle.bpel.client.NormalizedMessage;
    import com.oracle.bpel.client.delivery.IDeliveryService;
    import java.util.Hashtable;
    import java.util.Map;
    import com.oracle.bpel.client.ServerException;
    import java.rmi.RemoteException;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import org.w3c.dom.Element;
    public class CallBPEL {
    public CallBPEL() {
    public static void main(String[] args) {
    CallBPEL callBPEL = new CallBPEL();
    Hashtable env;
    try {
    env = callBPEL.getInitialContext();
    String xml = "<ssn xmlns=\"http://services.otn.com\">" + "1234" + "</ssn>";
    Locator locator = new Locator("default",env);
    IDeliveryService deliveryService = (IDeliveryService)locator.lookupService
    (IDeliveryService.SERVICE_NAME );
    NormalizedMessage nm = new NormalizedMessage();
    nm.addPart("payload", xml);
    try {
    deliveryService.post("JavaCallingBPEL", "initiate", nm);
    System.out.println("BPELProcess HelloWorld executed!<br>");
    } catch (ServerException e) {
    e.printStackTrace();
    } catch (RemoteException e) {
    e.printStackTrace();
    } catch (NamingException e) {
    e.printStackTrace();
    } catch (ServerException e) {
    e.printStackTrace();
    private static Hashtable getInitialContext() throws NamingException {
    Hashtable env = new Hashtable();
    env.put("orabpel.platform","ias_10g");
    env.put("java.naming.factory.initial","com.evermind.server.rmi.RMIInitialContextFactory");
    env.put("java.naming.provider.url","opmn:ormi://localhost:6004:oc4j_soa/orabpel");
    env.put("java.naming.security.principal","oc4jadmin");
    env.put("java.naming.security.credentials","welcome1");
    return env;
    I am breaking my head since last two days. i dont know whats the problem. i have included almost all the jars in class path.
    Can anybody help me in this.
    any help is appreciated.
    Thanks,
    Nimisha

    Hi all,
    I have solved above problem but run into some other exception below
    Dec 22, 2008 12:51:34 PM oracle.j2ee.rmi.RMIMessages EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER
    WARNING: Exception returned by remote server: {0}
    com.evermind.server.rmi.RMIConnectionException: Disconnected: com.oracle.bpel.client.AbstractIdentifier; local class incompatible: stream classdesc serialVersionUID = 3174123903773674079, local class serialVersionUID = -4389351842028223514
         at com.evermind.server.rmi.RmiCallQueue.notifyQueuedThreads(RmiCallQueue.java:70)
         at com.evermind.server.rmi.RMIClientConnection.notifyQueuedThreads(RMIClientConnection.java:154)
         at com.evermind.server.rmi.RMIClientConnection.resetState(RMIClientConnection.java:128)
         at com.evermind.server.rmi.RMIConnection.receiveDisconnect(RMIConnection.java:233)
         at com.evermind.server.rmi.RMIClientConnection.receiveDisconnect(RMIClientConnection.java:140)
         at com.evermind.server.rmi.RMIConnection.handleOrmiCommand(RMIConnection.java:208)
         at com.evermind.server.rmi.RMIClientConnection.processReceivedCommand(RMIClientConnection.java:222)
         at com.evermind.server.rmi.RMIConnection.handleCommand(RMIConnection.java:152)
         at com.evermind.server.rmi.RMIConnection.listenForOrmiCommands(RMIConnection.java:127)
         at com.evermind.server.rmi.RMIConnection.run(RMIConnection.java:107)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:819)
         at java.lang.Thread.run(Thread.java:595)
    Any Idea?
    Thanks,
    Nimisha
    Edited by: user649974 on Jan 6, 2009 10:50 AM

  • Call ESB from Java Class

    Hi, I want to call a BPEL process through the ESB using java. How can i do it? And if my BPEL process is synchronous, how can i route the reply back to the java class that is waiting for the response?

    I have a struts project that calls a BPEL process and waits for the response.
    IDeliveryService svc =
    (IDeliveryService)locator.lookupService(IDeliveryService.SERVICE_NAME);
    NormalizedMessage msg = new NormalizedMessage();
    HashMap properties = new HashMap();
    //Add properties for instance lookup
    properties.put("conversationId", reservationId);
    msg.addPart("payload", message);
    msg.setProperties(properties);
    processName = "BPELProcessSeguros";
    if (operation.equals("Claim")){
    operation = "claim";
    NormalizedMessage resp = svc.request(processName, operation, msg);
    Map payload = resp.getPayload();
    org.w3c.dom.Element result = (org.w3c.dom.Element) payload.get("payload");
    System.out.println("@@output payload ["+result+"]");
    Now, i want to change this call for another one that call the BPEL process trough the ESB.

  • Call a function in servlet from java class.

    Hi,
    I am implementing a client/server technology by trying to convert a java desktop client into Browser based. As part of user authetication the only way I know that a username /password does not match is from the servers message as i dont have documentation of the backend servers database.
    Here is a fucntion which receives lines form server.
    public class ServerComm{
    public synchronized void receiveMessage(String  serverMessage){
    if (serverMessage.equals("Login-Fail"))// Login-Fail is message from server if login fails
    LoginHandler.loginFail()//Login Handler is a servlet
    return
    }The Login Handler servlet is as follows.
    public class LoginHandler extends HttpServlet {
        /** Initializes the servlet.
        public void init(ServletConfig config) throws ServletException {
            super.init(config);
        /** Destroys the servlet.
        public void destroy() {
        /** Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
        protected synchronized void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    //some expressions.       
       //this is reached if login fails.
        public static void  loginFail(){
            HttpServletResponse response;
        //redirected to wronglogin web page.  
      response.sendRedirect("/mCVW/wronglogin.jsp");
        /** Handles the HTTP <code>GET</code> method.
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
        /** Handles the HTTP <code>POST</code> method.
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            processRequest(request, response);
       }Now there is problem in loginFail() method in LoginHandler servlet does not work with the type of response decleration . I need some assistance from any one to make this work or propose a better solution for determining the user authetication with the restriction i have.
    Thank you.

    hmm...I haven't tried this before...but does this work by any chance?
    In your ServerComm class, create new HttpServletRequest and Response objects and get a RequestDispatcher object from request.
    Eg : if (serverMessage.equals("login-fail"){
    HttpServletRequest request = new HttpServletRequest ();
    HttpServletResponse response = new HttpServletResponse ();
    request.setAttribute("function_id", "loginFail");
    RequestDispatcher dispatcher = request.getRequestDispatcher("http://servername:port/ServletName");
    //give the complete path of your servlet
    dispatcher.forward(request, response);
    and in your Servlet, get this function_id and if its loginFail, redirect it to wronlogin.jsp...
    public class MyServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    String function_id = request.getAttribute("function_id");
    if(function_id.equalsIgnoreCase("loginFail"))
    //forward to ur jsp
    getServletConfig().getServletContext().getRequestDispatcher(wronlogin.jsp").forward(request, response);
    }

  • Calling a servlet in java class

    Hello,
    I try to call a servlet from java class
    but is dose not work
    what should be the problem
       public void callServlet()
              try
                            // xxservlet is the servlet name
                   URL url = new URL("http://www.mydomain.com/xxservlet");
                   URLConnection hpCon = url.openConnection();
                   hpCon.setDoOutput(true);
                   OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
                   out.write("This Is a Test");
                   out.flush();
                   out.close();
              }catch(Exception ex){ex.printStackTrace();}     
    // My Servlet  is in package servlets
    public class XXServlet extends HttpServlet
        public void service(HttpServletRequest req, HttpServletResponse resp) {
            try {
                 ServletInputStream sin = req.getInputStream();
                 int len = req.getContentLength();
                    byte[] input = new byte[len];
                    ServletInputStream sin = req.getInputStream();
                   int c, count = 0 ;
                   while ((c = sin.read(input, count, input.length-count)) != -1) {
                       count +=c;
                  sin.close();
                  String inString = new String(input);
                  System.out.println("Servlet is running ...."+inString);
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    // web.xml
    <servlet>
           <servlet-name>xxservlet</servlet-name>
           <servlet-class>servlets.XXServlet</servlet-class>
        </servlet>
       <servlet-mapping>
        <servlet-name>xxservlet</servlet-name>
        <url-pattern>/xxservlet</url-pattern>
      </servlet-mapping>
    }regards
    Edited by: the_Orient on Mar 30, 2009 3:16 AM

    I have start servlet from brwoser only to test that servlet works fine
    A gain what I need
    I want to call a servlet from a javs class
    URL url = new URL("http://www.mydomain.com/myservlet");
      URLConnection hpCon = url.openConnection();
      hpCon.setDoOutput(true);
      OutputStreamWriter out = new OutputStreamWriter(hpCon.getOutputStream());
      out.write("Hello Woprld");
      out.flush();
      out.close();// Servlet
    public void doGet(HttpServletRequest req, HttpServletResponse resp) {
            try {
                  String xp =req.getSession().getServletContext().getRealPath("/");
                  File f = new File(xp+"/students/info.txt");
                  f.createNewFile();
            } catch (IOException e) {
                try{
                    resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    resp.getWriter().print(e.getMessage());
                    resp.getWriter().close();
                } catch (IOException ioe) {
    problem file can not be created
        public void doPost(HttpServletRequest req, HttpServletResponse resp)
    }I hope that is clear

  • Calling servlets from main()?

    Hi
    I would like to know that while calling servlets from another class having main(), how can we set the type of request i.e. put, post or get?
    Thanks

    use the method - setRequestMethod( "POST") of HttpURLConnection for setting the method to POST.Similarly for other methods..
    You could find [url http://java.sun.com/developer/JDCTechTips/2004/tt0210.html#2]this useful

  • Calling Custom XSLT java class from BPEL in SOA Suite 11g

    Hi All,
    Morning...need some help with this issue...we are currently on SOA Suite 11g (11.1.1.4) version.
    Earlier while we were on SOA Suite version 10g (10.1.3.3) we were calling the custom java classes from the xsl mapping for complex transformation and for this we were placing the .class file as .jar file at the location mentioned here $OC4J_HOME/j2ee/home/applib directory and then mentioning the namespace as http://www.oracle.com/XSL/Transform/java/{$classname$} in the XSLT mapping file.
    Now in SOA Suite 11g if we need to retain similar functionality for external custom java calls could someone please help us where do we need to put the .jar file now ..
    exactly at which directory location/path and on which instance/server (application server instance or middle tier instance ) we need to put this .jar file
    Currently we are stuck and need some help with this.
    With thanks & Regards

    Hi Eric & Anuj,
    Thanks for replying , sorry for checking on this now...
    here at this path /opt101/app/oracle/SOAD/SOA11gR1/fmw/Oracle_SOA1/soa/modules/oracle.soa.ext_11.1.1
    we got the ora.soa.ext.jar file and extracted it to get the MANIFEST.mf file ..have mentioned below.
    Now if we need to link our custom .jar file named customfunctions.jar so we need to mention it as below is this correct :
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 17.0-b17 (Sun Microsystems Inc.)
    Implementation-Vendor: Oracle
    Implementation-Title: Oracle SOA EXT
    Implementation-Version: 11.1.1
    Product-Name: Oracle SOA EXT
    Product-Version: 11.1.1.4.0
    Specification-Version: 11.1.1
    Extension-Name: oracle.soa.ext
    Class-Path: classes/
    Class-Path:customfunctions.jar classes/ -- is this the way to mention (means we need to add this additional line or we need to add to the existing line at Class-Path: classes/)
    2.
    Eric the Alternative method mentioned in your update :
    Open a command prompt and change the current directory to the oracle.soa.ext_11.1.1 directory ,
    then execute the build.xml file in the oracle.soa.ext_11.1.1 folder using Ant
    Now could someone please guide us regards this ANT means how does it work and its relation to the build.xml file and how do we check whether we have ANT utility available or not..
    not much conversant with this ANT hence asking here..would lookout for your reply
    thank you

  • Calling a servlet from java

    How to call a servlet from java?
    your help is greatly appreciated..

    Welcome to the forum
    You seem to be misunderstanding something. Do some googling to learn what you need about servlets. Simplified, servlets are java code that's hosted by a web container, such as Tomcat. When a servlet gets called as a consequence of someone requesting a url from the container, it takes in a request object and a response object. All the magic is then in creating an appropriate response (e.g. html) for the incoming request.

  • Calling servlet from a java program

    Hi
    I need to call a servlet's doPost() method from a java program. I have a specific situation, where I need to call servlet from a java program. DUring this call I need to pass a file and two string to the servlet. Servelt after receiving the file and string uploads the file to the server at a specified location. I am stuck up as how to call servlet from a java program instead of a HTML or JSP.
    Can anyone help me to start with this.
    any suggestion is welcome.

    You have to establish a URLConnection with servlet from your java program.
    URL servletURL = new URL("http://localhost:8080/Myservlet?str1=abc&str2=def");
    URLConnection servletConnection = servletURL.openConnection();you can get the objectOutputStream
    ObjectOutputStream oos = new ObjectOutputStream (servletConnection.getOutputStream());
    oos.writeObject(your file object);-------------------------------------------------
    In the servlet u can get the strings using request.getParameter("str1");
    In the servlet u can get the strings using request.getParameter("str2");
    file = new ObjectInputStream (request.getInputStream()).readObject()a lot of resources are available on this ...
    hope this helps :)

  • Calling Servlet from a java prog?

    Hi all,
    I am calling servlet from a java prog (Java Agent in Lotus Notes) by using URL and URLConnection object. how can i trigger the Servlet By using doPost method .I have to send some parameter also.
    Thanx
    Muthu

    you need to open a connection to the servlet. Then you must call getInputStream() and getOutputStream() and use them in any way you see fit. I was trying this before and could not get POST to work unless I openned the input stream from the servlet. Strange... but doGet worked without openning the input stream???
    // open a connection....
    // write to the servlet
    servletConnection.getOutputStream().write("whatever");
    servletConnection.getOutputStream().flush();
    servletConnection.getOutputStream().close();
    // grab what the servlet sends back, required to do a post.
    byte [] in = new byte[100];
    servletConnection.getInputStream().read(in);
    servletConnection.getInputStream().close();

Maybe you are looking for

  • RingTone Help

    Hello, Ok according to the iTunes Store Beautiful Girls by Sean Kingston should be ring tone working. But in the Purchased Tab under iTunes Store that song is not popping up with the ringtone icon. A ton of my other songs are popping up with that ico

  • How do I get the add-on for HP SimplePass Identity Protection

    My computer has the fingerprint security feature using Windows 7. Since I added Firefox after I used my new HP Laptop, their help info indicated that I would have to add the add-on manually. When I go to the Firefox Add-on page, there is no add-on li

  • UDF update field using Query

    Hi All, I have a udf field in OITM which we use to flag whether an item is obsolete or not, so Y or N is populated in all item records. I am trying to copy this field and its contents to be displayed in the Stock Data Tab (OITW) using a UDF but canno

  • NWA - Logs and Traces Not available

    Hello All, I am unable to view the logs and Traces , When I am accessing it through NWA for example http: <server>:<port>\nwa ...... In Monitoring --> Logs and Traces --> when I select Default Trace , Its asks me for the setting up the data source ,

  • How i can change country if i have balance ?

    I want change my apple id to saudi arabia