Servlet to Remote Servlet File Transfer

Hey there, this is my very first post :)
I've been surfing the forum for a solution to my problem but have had no luck so far.
The problem is:
I want a client to upload a file to a servlet. (easy part)
And then i want to that servlet to upload that file to another servlet on a different server. (hard part)
Why?
Because we have many backup servers and test servers that have to be the same i.e contain the same images,html pages,files etc.
And we want an easier why to synchronise them other than doing it via copy paste methods for each server... very time consuming.
Just wondering if anyone has tried to do this?
and
If anyone knows of a way to transfer a file from a servlet to another servlet on a different server?
or
If you know an easier way to do this then servlet to servlet file transfer, your insight would be much appreciated.
Code examples would be very helpful or relevant links.
Thanks for you time
dudz_josh

use HttpUrlConnection in 1 servlet to get a connection to
the 2 servlet.
then 1 get OutPutStream and write file.
in 2 get InputStream and read file
or
add the file object/stream to the request and forward it
too the other servlet.
the file is just a java object

Similar Messages

  • Connecting to a remote servlet from an unsigned applet

    My applet connects to a remote servlet (on a different server). I could obviously connect to it fine with a signed applet, but now my applet is no longer signed.
    I understand an unsigned applet can access a servlet on the same web server host, but the problem is that the servlet is on a different server...
    Is there some simple way I can create a file (html or whatever) on the web server host that can accept requests from the applet and redirect them to the remote servlet?
    Cheers,
    James

    If I understand what you're saying, no.
    But perhaps you can install the applet on the server that you want to connect to.

  • Remote Execute and File Transfer Error

    Whenever we try to do a Remote Execute of File Transfer, we get an 1899
    error. Here's the strange thing, we can RE and FT to desktops that are
    still running the ZfD 4.x client. Seems to be only happening on the latest
    (ZfD 6.5sp2). Any ideas? Also, remote control and remote view still work
    w/o problem.

    Blewis,
    It appears that in the past few days you have not received a response to your
    posting. That concerns us, and has triggered this automated reply.
    Has your problem been resolved? If not, you might try one of the following options:
    - Do a search of our knowledgebase at http://support.novell.com/search/kb_index.jsp
    - Check all of the other support tools and options available at
    http://support.novell.com.
    - You could also try posting your message again. Make sure it is posted in the
    correct newsgroup. (http://support.novell.com/forums)
    Be sure to read the forum FAQ about what to expect in the way of responses:
    http://support.novell.com/forums/faq_general.html
    If this is a reply to a duplicate posting, please ignore and accept our apologies
    and rest assured we will issue a stern reprimand to our posting bot.
    Good luck!
    Your Novell Product Support Forums Team
    http://support.novell.com/forums/

  • Interesting ? @ servlet reading a txt file

    hi friends,
    i need ur help for one interesting problem i m facing.
    I want to read a txt file and wanna display the text from that file into an html, using a servlet.A txt file contains sentences( words with spaces in between ).When servlet reads the file, it is reading the whole sentence ,but while displaying that sentence, it is just showing the first word of the sentence.
    html is not able to read the space between the words.
    so what do i suppose to do now.
    waiting for ur replies.......
    thanx
    amit

    hi friends ,
    i m giving the code , just give it a try//
    This is a servlet ---------------------------------------
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class AdminGraphServlet extends HttpServlet
    Properties ht;
    FileInputStream fin;
    FileOutputStream fout;
    String s15,st;
    public void init(ServletConfig config) throws ServletException
    super.init(config);
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException
    ht = new Properties();
    try
    fin = new FileInputStream("Data.txt");
    catch(FileNotFoundException e)
    System.out.println("FileNotFound");
    try
    if(fin != null)
    ht.load(fin);
    s15 = (String)ht.get("title");
    fin.close();
    catch(IOException e)
    System.out.println("Error Reading File");
    PrintWriter out = res.getWriter();
    res.setContentType("text/html");
    out.println("<html><body>");
    out.println("<form method=post action=http://localhost:8080/servlet/MyServlet>");
    out.println("<table><tr>");
    out.println("<tr><td>Title</td>");
    out.println("<td><Input Type=Text name=title value="+ s15 +"> </td></tr>");
    out.println("</table>");
    out.println("<input type=submit name=submit value=submit>");
    out.println("<input type=hidden name=check value=save>");
    out.println("</form>");
    out.println("</body></html>");
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException
    String Scheck = req.getParameter("check");
    PrintWriter out1 = res.getWriter();
    String ttl = req.getParameter("title");
    if(Scheck.equals("save"))
    ht.put("title",ttl);
    fout = new FileOutputStream("Data.txt");
    ht.store(fout,"Data");
    fout.close();
    out1.println("<html><body>");
    out1.println("<h1>Stored This Data Successfully</h1>");
    out1.println("</html></body>");
    txt file is having a line
    title=Are you smart enough?
    The servlet should display this sentence in a text box.
    But it is displaying only "Are".
    still waiting...
    have nice time..
    amit

  • Compiling the java file related to Servlet and Core java files in heirarchy

    I am working in Jakarta-Tomcat 4.0.4 with j2sdk1.4.1_01 and i have put all servlet files in package "com.java.servlet"
    and other core java files in package "com.java.action" . Also I am imorting java files in package
    "com.java.action" to the package "com.java.servlet".
    But when I am compiling the servlet files in package "com.java.servlet"
    then the servlet files are not compiling because it cannot able to import
    java files in package "com.java.action" . I have tried all the options.
    If anybody has solution then please respond immediately.

    I agree with the previous poster, this sounds like a generic compiling problem. FYI: I do not think that packages that start with "com.java." are special or reserved in any way.
    You are making a servlet, not a JSP, right? Since this is merely about compiling, you might want to re-post to "Java Programming".

  • Tomcat servlet/JSP container default files on 10gAS(10.1.2.0.2)

    Hi Friends,
    I am using Oracle Application Server 10g (10.1.2.0.2) on windows
    I have the Vulnerability: Apache Tomcat servlet/JSP container default files.
    and the fix is Review the files and delete those that are not needed.
    i would like to know the location of the files to review and delete.Please suggest?
    Regards,
    DB

    Apache/Tomcat is not related to OAS, where did you get this info? OAS is based in a Orion Web Server and Apache HTTP Server, not Tomcat.
    For this kind of problems there are the CPU you may want to check in Metalink for them.
    Can you clarify also what default files?
    Greetings.

  • Servlet as a welcome file: is it a myth?

    Hello
    There are many articles on the web that espouse that Servets 2.4 allow for a servlet to be specified as a welcome file thusly (taken from OnJava.com):
    First, register the servlet in web.xml.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi=
    "http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=
    "http://java.sun.com/xml/ns/j2ee
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <servlet>
    <servlet-name>MyServlet</servlet-name.
    <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <!-- optionally map the 'MyServlet' servlet to a URL pattern -->
    <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <!-- rest of web.xml ... -->
    Then create a welcome-file element in web.xml that specifies the registered servlet name.
    <welcome-file-list>
    <welcome-file>MyServlet</welcome-file>
    <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    Make sure to use the servlet name in the welcome-file element without a forward slash (/) preceding it.
    Poppycock I say. At least it's not working for me with either Tomcat 5 or Tomcat 5.5. Has anyone out there ever seen this work on Tomcat?

    It most certainly is possible now, but wasn't until rather late in TC 5.0.xx series I believe (5.0.18 or so?). You can chack the change logs to id exactly when...
    But the reason it isn't working for you is you have to match the value in your <welcome-file> to the URL in the servlet's <url-pattern> servlet mapping. So your web XML should look like this:
    <servlet>
      <servlet-name>MyServlet</servlet-name.
      <servlet-class>com.jspservletcookbook.MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
      <servlet-name>MyServlet</servlet-name>
      <url-pattern>/myservlet</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
      <welcome-file>myservlet</welcome-file>
      <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>Your porblem was case. Your url-pattern had lower case, but the welcome-file had upper case letters like the servlet name.
    Here is an example app that I tested and worked:
    //The servlet:
    package net.thelukes.steven;
    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class WelcomeServlet extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
           throws ServletException, IOException {
              PrintWriter out = response.getWriter();
              out.println("Hello World");
              out.flush();
              out.close();
    //the web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4"
             xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
                                 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
         <display-name>WTPTest</display-name>
         <servlet>
              <servlet-name>Welcome</servlet-name>
              <servlet-class>net.thelukes.steven.WelcomeServlet</servlet-class>
         </servlet>
         <servlet-mapping>
              <servlet-name>Welcome</servlet-name>
              <url-pattern>/welcome</url-pattern>
         </servlet-mapping>
         <welcome-file-list>
              <welcome-file>welcome</welcome-file>
         </welcome-file-list>
    </web-app>
    //The address I typed (the web app is names WTPTest
    http://localhost:8080/WTPTest
    //The HTML Output
    Hello World

  • Servlet for downloading a file

    i am writing a servlet for downloading a file on a GET action in the form..the web-xml is deployed correctly as far as i can interpret..bt i am encountering an error during the run time..
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    here is the log file..
    Jul 11, 2008 12:07:14 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet DwnFile threw exception
    java.lang.NullPointerException
         at com.example.web.dwnfile.doGet(dwnfile.java:17)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    it has some more content bt it is just the exceptions thrwn...
    and here is my *.java file*
    package com.example.web;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    public class dwnfile extends HttpServlet
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
    response.setContentType("/image/jpeg");
    ServletContext ctx=getServletContext();
    InputStream is=ctx.getResourceAsStream("/2004.jpeg");
    int read=0;
    byte[] bytes=new byte[1024];
    OutputStream os=response.getOutputStream();
    while ((read=is.read(bytes))!=-1)
    {os.write(bytes,0,read);
    os.flush();
    os.close();
    the bold line is whre the exception is pointing..i think..
    thanks in advance..
    Edited by: Sun_Rockz on Jul 10, 2008 7:13 PM

    response.setContentType("/image/jpeg");
    ServletContext ctx=getServletContext();
    InputStream is=ctx.getResourceAsStream("/2004.jpeg");there was an error in this part of code..the image extension of .jpeg is not allowed it seems..on changing it to jpg worked..and
    in the first line the contenttype mst not be preceded by a forward slash..
    now one more doubt relating to the same servlet..
    response.setContentType("application/x-zip");
    ServletContext ctx=getServletContext();
    InputStream is=ctx.getResourceAsStream("/servlet_spec.zip");
    if i keep this in my servlet the required action is taking place..i.e.i am gettin a download option bt the problem is tht the file is getting downloaded as a download.do file.....
    download.do is the url pattern tht i am using in my html web page..
    i tried replacing different types of allplications and files bt all are downloaded wit the same name. i.e. download.do
    so what do u think is reason behind this..
    thanks for all the replies.
    Edited by: Sun_Rockz on Jul 11, 2008 10:47 AM
    Edited by: Sun_Rockz on Jul 11, 2008 10:51 AM

  • Deploying the JSPs, Servlets and Java class files

    Hello All,
    I'm very new to the Oracle 9i AS. We are using Version 1.0.2.2.
    How do we deploy the JSPs, Servlets, and Java class files (simple class files, not EJBs)?
    plese give us the procedure and stpes how to deply or the links for the same.
    Thanks,
    Santhosh.

    Hi
    I guess u r running apache-jserv as servlet engine for your jsp and servlets. If its so, jsp files can be run without any additonal configuration by putting the jsp file under document root or any subdirectory and for running servlets u have to add classpath entries for your servlet in jserv.properties file.
    To make sure that your servlet engine is working, try
    http://servername:port/servlet/IsItWorking, if u get success msg that means servlet engine is working fine.
    Hope this will help
    Regards
    Kumaran

  • Can I use servlet as my welcome file

    How can I use servlet as my welcome file? I know how to use jsp or html pages as my welcome file but that doesn't work for servlets. I modified my web.xml for making jsps and html as my welcome pages but that <welcome-file-list> tag is not working for servlets.

    This was a bug that occured in older Tomcat programs, not sure if it still occurs or not.
    Basically, when this happens, you have to have a physical file with the welcome file name. So you would have to create a file named index.do in each of your directories you wanted the welcome to work for. The index.do wouldn't have to actually do anything. It just had to exist. Then when the URL was used to create content, the servlet would be called to create that content.

  • File transfer option not available for remote devices under MAX

    I am currently using LabVIEW 2012 and am using a application running on a Windows 7 PC to communicate (TCP/IP over Ethernet) with a RT PC.  I have built an installer that installs a LabVIEW application as well as MAX on the Windows 7 PC.  After installation i can open MAX and browse under Remote Systems to my RT device but am unable to ftp files to the the RT device as the File Transfer feature on the drop down menu is not shown. (This PC does not have the LabVIEW development environment installed.)  Does anyone know if there are Additional Installers that are required to be included that will activate this feature or any reason why this feature in not available?
    Regards,
    Rob  

    Did you include the MAX FTP Client from the RT module in your installer? See this knowledgebase to see what I mean:
    http://digital.ni.com/public.nsf/allkb/571113c2ce05998e862574e8006005a2?OpenDocument
    Also, you can most likely just do ftp using windows explorer, if you prefer that method. Just open up windows explorer, and in the address bar type "ftp://x.x.x.x/" (where x.x.x.x is the IP address of the RT PC you are accessing.
    Also, are you using the LabVIEW real-time module on your RT PC?
    Colden

  • Help needed in Mapping servlet in web.xml file

    Hi Can anyone please tell me what am doing wrong here. I can't see this servlet in my url. Please help.
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
         <servlet-class>HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/com/jci/fi/application/eems/HelloWorld/*</url-pattern>
    </servlet-mapping>
    package com.jci.fi.application.eems;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    out.println("<html>");
    out.println("<body>");
    out.println("<head>");
    out.println("<title>Naveen Wants to goto TollyWood......!</title>");
    out.println("</head>");
    out.println("<body>");
    out.println("<h1>Hello World!</h1>");
    out.println("</body>");
    out.println("</html>");

    your web.xml shoould be something like this...
    <servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>com.jci.fi.application.eems.HelloWorld</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>HelloWorld</url-pattern>
    </servlet-mapping>
    Hope this helps..
    CK

  • File Transfer b/w Client - Server using JSP

    Hi,
    I need to implement a file transfer between the client and the server using JSP / Beans. The files can be XML Documents, Images (.gif,.jpeg) or even MS Word documents.
    The user has a set directory on his file system where the files are to be saved upon download and retrieved upon upload. This system is similar to a check-in check-out system.
    How do I get a reference to the directory on the users file system and then either save the downloaded files there or retrieve the files that need to be uploaded.
    Thanks
    coffeejava

    The only way you can do this is by using an applet, a jsp page or servlet does not have access to the system that the browser is running on. Furthermore if you were planning on using the html file form object you cannot set a value for that programmatically. It's not allowed for security reasons.

  • Can we able to write code File transfer protocol code in HTTPServlet file ?

    Can we able to write code File transfer protocol code in Http file ?
    if Yes , give some details about how to write
    if No, give some reason why not .
    Thanks

    Hi Paul(DrClap)
    My question is ,if we are using a java
    file(servlet) which is handing httprequest , can we
    use this to handle FTP request also.As I already said, you can't use a servlet as an FTP server.
    can we able to write FTP code in above mentioned file?As I already politely pointed out, "FTP code" is ambiguous until you specify whether you mean server or client code.
    So. If you don't understand what clients and servers are, then drop this question and go away until you do understand. It's not that complicated.
    And please don't waste my time by responding with the same questions over again.

  • XML file transfer between ASP & JSP

    Hi !
    Actually the requirement is to provide an interface between an ASP application and a JSP application.
    What i could understand is that commonly used way is transfering XML files using SOAP.
    But, i have no idea on SOAP and need few clarifications.
    1. What are the roles of SOAP, WSDL and UDDI ? and does SOAP needs WSDL or UDDI and web services?
    2. Do i need to use web services just to transfer XML file from ASP to JSP ?
    3. is HttpURLConnection also used in this approach ?
    actually what my purpose is to know that to implement SOAP for XML file transfer what all i need to do ?

    Hi !
    Actually the requirement is to provide an interface
    between an ASP application and a JSP application.
    What i could understand is that commonly used way is
    transfering XML files using SOAP.
    But, i have no idea on SOAP and need few
    clarifications.
    1. What are the roles of SOAP, WSDL and UDDI ? and
    does SOAP needs WSDL or UDDI and web services?SOAP is a transfer protocol for exchanging structured and typed information : go to the w3 web site to understand better.
    WSDL are files to describe a web service : you will find inside an access point and signatures from your methods; if you want it's a little bit like an interface in java but with more informations. You don't need wsdl for soap.
    Last uddi is a repository for web services. You need to publish your service inside a Uddi registry and it's associated access point and tmodel (go to oasis web site for more informations). It's a little bit like yellow pages. You need to use Uddi only if you want to discover serviecs dynamically.
    Usually you use SOAP by calling a web services, as a web service is over the SOAP layer. The advantages of using SOAP is that it describes your data too. In fact if you have complex types to transfer between your two applications the partners have to know how to understand these data.
    2. Do i need to use web services just to transfer XML
    file from ASP to JSP ?Well, what do you want to transfer exactly between your applications. If this is just a text stream you can simply send your file by opening a socket. But if you want to work with your informations, to use them (that means you have to build the corresponding object) you could use web services as your informations are explicitely defined : what do you want to do exactly ? Last but not least if you have already XML file you can get your info directly and parse ir or ????
    3. is HttpURLConnection also used in this approach ?Yes you could call a servlet or something like that to transmit your informations
    actually what my purpose is to know that to implement
    SOAP for XML file transfer what all i need to do ?you have to be more precise with what you want to do with the info; simply display it or ???
    PA
    http://www.doffoel.com

Maybe you are looking for