Servlet to Desktop App

I have a speecific question...
I have a mobile device connecting to a servlet, when the mobile device does some action, the action is sent to the servlet.
I then want the servlet to do some action to the desktop application.
I want to know is it possible to have the servlet and the desktop app communicate simply?
They are on the one machine and i want to avoid using the net for them to talk to each other
Thanks

Open an URL connection using java.net.URLConnection (and if necessary send the POST request), obtain the response as inputstream and process it.
There is an URLConnection tutorial available: http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html

Similar Messages

  • How To Launch Servlet from Desktop App

    Hello Everyone,
    I recently started my programing in JavaEE. First lesson was Servlets.
    My servlet takes the name and a number from a user using a html form and returns a wellcoming message to the user and calculates PI with "number" decimals.
    Well it works using a html form but the next exercise is to launch the servlet from a desktop application. I searched like 2 hours on google and different sites for this. I saw a hint about creating a framework(code was writen in 2001).
    I really really have no idea how to launch the Servlet from a desktop client application.

    The exercise says:
    PI Servlet
    Write a servlet capable of calculating the PI number with a specified number of decimals. Access this servlet:
    1. From a browser, using a HTML form
    2. From a desktop application
    For the calculation of PI use Machin formula PI/4 = 4 arctan(1/5) - arctan(1/239) or a similar one.
    For the calculation of arctan function use Taylor series: arctan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 + (x^9)/9 ...
    My servlet looks like this: without the Methods for calculating PI:
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
             try {
                int len = request.getContentLength();
                byte[] input = new byte[len];
                ServletInputStream sin = request.getInputStream();
                int c, count = 0 ;
                while ((c = sin.read(input, count, input.length-count)) != -1) {
                    count +=c;
                sin.close();
                String inString = new String(input);
                int index = inString.indexOf("=");
                if (index == -1) {
                    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    response.getWriter().print("Eroare la servlet");
                    response.getWriter().close();
                    return;
                String value = inString.substring(index + 1);
                //decode application/x-www-form-urlencoded string
                String decodedString = URLDecoder.decode(value, "UTF-8");
                int decc = Integer.parseInt(decodedString);
                String result = CalculatePI(decc).toString();
                PrintWriter out = response.getWriter();
                try {
                out.println("<html>");
                out.println("<head>");
                out.println("<title>Pi Servlet</title>");
                out.println("</head>");
                out.println("<body>");
                out.println("<h1>Pi Servlet  </h1>");
                out.println("<p> Wellcome <br /> PI cu "+ decodedString + "zecimale este: <p>");
                out.println("<br />" + result);
                out.println("</body>");
                out.println("</html>");
            } finally {
                out.close();
                // set the response code and write the response data
                response.setStatus(HttpServletResponse.SC_OK);
                OutputStreamWriter writer = new OutputStreamWriter(response.getOutputStream());
                writer.write(decodedString);
                writer.write(result);
                writer.flush();
                writer.close();
            catch (IOException e) {
                try{
                    response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
                    response.getWriter().print(e.getMessage());
                    response.getWriter().close();
                catch (IOException ioe) {
        } The Html form :
    <form action="PiServlet" method ="POST">
        Give PI decimals <input type="text" name="PI" size="20"><br />
        <input type="submit" value ="Submit" >
        <input type ="reset" value="Reset" >
    </form>And my desktop application :
    public static void main( String [] args ) throws Exception {
               if (args.length != 1) {
             System.err.println("errrrr");
             System.exit(1);
         String piString = URLEncoder.encode(args[0], "UTF-8");
         URL url = new URL("http://localhost:8084/MySecondServlet/");
         URLConnection connection = url.openConnection();
         connection.setDoOutput(true);
         OutputStreamWriter out = new OutputStreamWriter(
                                  connection.getOutputStream());
         out.write("string=" + piString);
             System.out.println(piString);
         out.close();
         BufferedReader in = new BufferedReader(
                        new InputStreamReader(
                        connection.getInputStream()));
         String decodedString;
         while ((decodedString = in.readLine()) != null) {
             System.out.println(decodedString);
         in.close();
        }Edited by: ELuCID on Jul 22, 2009 9:42 PM
    Edited by: ELuCID on Jul 22, 2009 10:11 PM

  • How to connect a Desktop app to a middle teir server app?

    Please tell me if i have posted this in the incorrect forum.
    I currently have a Desktop app that connects directly to a mySQL database. The persistence abilities have been really helpful since our database is still evolving. I have been frustrated by the differences in the SE persistence implementation. I have had to do some hackish things to ensure that the app retrieves the current information. I don't like connecting directly to the database from the desktop app, even though security is not a worry. I have been thinking that the best solution is to have a JEE app running that the desktop app connects to. This also would act as a sort of api for accessing our data, so if and when i create other client desktop apps i don't have to recreate the wheel. From what i gather i will want to run an application server such as tomcat or glassfish. I'm not sure if i understand why though. Since i have control of the server, couldn't i directly open ports for communication to the clients?
    Assuming that there are many ways to pass information between them, advice on the most effective would be nice. I'm guessing serializing objects for passing would be the fastest, but using something like XML, would be a lot easier to monitor.
    Although i have done a lot of reading, i'm still baffled by the EE lingo.
    EJB: kind of like a modular program that facilitates server to server communication?
    JSF: package up stuff for viewing/ running an application through a browser?
    Servlets: Mystifying, which leads me to think that they are what i'm looking for.
    Any advice would be helpful. I'm hoping that there is not some type of restriction in regards to connecting a JSE6 app to a JEE6 app. I basically want to have the best of both worlds.
    Thank you,
    Chip

    Chipper wrote:
    From what i gather i will want to run an application server such as tomcat or glassfish. I'm not sure if i understand why though.If you have a middle teir, you imply that you want frontend and a backend also, the function of the middle teir is to insolate and abstract the backend from the frontend. This is the significant difference from what you have now: client server--frontend and a backend.
    The middle tier, as you have implied, is where you put your access to your backend. And, yes, you are creating an interface to your DB there, wherein you will develop an entire API for accessing your DB. This will give you added security by not letting your clients know anything about your backend.
    Now, how do you access this middle tier? There are several options there, but a few options are:
    1 - Running direct socket communication
    2 - Web Services: code ran on the server to extend the functionality and open services on the middle tier.
    3 - Applets: code ran in the browser on client side to access the server and it's services.
    Assuming that there are many ways to pass information between them, advice on the most effective would be nice. I'm guessing serializing objects for passing would be the fastest, but using something like XML, would be a lot easier to monitor.At this point you are the only one that can answer that question: there are arguments for an against most method that could be picked. Let's take for instance an object that contains 1 usable byte of data. Is it better to serialize the object for that one byte? Send XML to a DB? Or, perhaps, just send the byte of info and synthesize appropriate key information? You have to look at what you are trying to achieve and your requirements.
    Even a scratch of the surface discussion is not possible here, let alone, a howto on implementation for your enterprise. I suggest hitting the tutorials and finding a good book.
    Do you have specific questions? Ones that can be answered in a paragraph or two.

  • Webstart-deployed desktop app, command line and Windows ShellExecute.

    Hi all,
    I want to be able to associate Windows Shell registry actions (shellExecute from right click menu, double click, and protocols) with a Webstart Java Swing desktop app. This is pretty key to our deployment strategy.
    I have two options that I'm pursuing right now.
    OPTION A
    Unfortunately I'm encountering a few problems:
    1) javaws.exe does not accept parameters, therefore I can't pass parameters directly from a Windows command line
    2) The only way to get arguments in is through the jnlp file. Sounds like this is possible using a jnlp written by a servlet. But can I just pass GET parameters to my servlet like so?
    http://webstart.com/go/?param=value&param2=value2Would that work?
    2a) subissue: I want to use JNLP's SingleInstance to make sure that only one of my app is running at any time. It sounds like that JNLP interface also allows for new parameters to be passed in as arguments... but if I pass in parameters to my webstart address, will SingleInstance properly recognize that http://webstart/go and http://webstart/go?param=value are the same program?
    OPTION B
    So the alternative deployment strategy that I'm contemplating is using webstart, but then deploying a separate .jar to the machine and registering that to be the argument acceptor from Windows. So windows would run something like so:
    java -jar cmdLauncher.jar argshereFrom there I will do two things:
    a) If the program is already running, then I pass the argument in using network sockets and deal with it like so.
    b) If the program isn't already running, then I execute javaws http://myurl and then maybe write to the socket when it's ready. This might really suck since i'll have to poll until the socket is ready.
    Anyway, was hoping someone with more webstart internals had some idea as to
    a) would a option A (dynamic servlet) work in the way I expect?
    b) Is option B the only way to really do it? It certainly seems feasible at this point.
    Ideally I just wish javaws.exe allowed passing arguments, and thus this entire problem would not exist. It's a pretty powerful and important feature for WebStart to be able to be a fully featured deployment solution.

    OPTION A
    Unfortunately I'm encountering a few problems:
    1) javaws.exe does not accept parameters, therefore I
    can't pass parameters directly from a Windows command
    line
    2) The only way to get arguments in is through the
    jnlp file. Or the SingleInstanceService.
    ....Sounds like this is possible using a jnlp
    written by a servlet. But can I just pass GET
    parameters to my servlet like so?
    http://webstart.com/go/?param=value�m2=value
    2Would that work?Huh? Assuming the servlet that produces the
    launch file fir this application is called 'go', and that
    servlet returns the correct content-type, and writes
    the two params in the URL into the JNLP as
    arguments, then.. yes - this should work.
    http://webstart.com/go?param=value�m2=value2Note the lack of one '/'.
    ( I have not had much direct experience with
    JNLP combined with servlets, but am familiar
    with both. )
    2a) subissue: I want to use JNLP's SingleInstance to
    make sure that only one of my app is running at any
    time. It sounds like that JNLP interface also allows
    for new parameters to be passed in as arguments...
    but if I pass in parameters to my webstart address,
    will SingleInstance properly recognize that
    http://webstart/go and http://webstart/go?param=value
    are the same program?As I understand from my experience, the URL
    becomes redundant, any params that were in
    the JNLP are ignored in preference to the single
    -open argument. Here is my buildable example..
    http://www.physci.org/jws/#sis
    a) would a option A (dynamic servlet) work in the way
    I expect?Sounds like it.

  • Download error in (osx) adobe desktop app (corrupted download link).

    Here is a discription of the problem. Please consider that some of the wording might not be correct, as I do have to translate the error message from German into English.
    Using OSX 10.9.2, when clicking inside the adobe desktop app (top of the screen bar) on the tap "apps", the following screen (screenshot) appears, which states, translated from top to bottom:
    download error
    download error. Please contact support.
    (link) contact support
    (link/button) download creative cloud -> This button unfortunatly leads to the following error page "http://www.adobe.com/special/errorpages/404.html"
    All apps, like Bridge, Photoshop, Lightroom, etc. are installed and work just fine. So no problem here. I seem however unable to redownload the desktop app (in order to reinstall). As stated above the provided link inside the desktop app itself is coruppted and within the (online) web-based download centre (user logged in) I am only adviced to use the desktop app. This is a dead end and I do not know what to make of this error, let alone solving it. Please help!

    I am sorry Romsinha but this doesn't really help.
    I already restarted the desktop app and while I am obviously online and connected the problem (error message) remains the same. Information within the "home" tap is recieved/loaded  (little blue spinning wheel) stating that various apps recently have been updated. Yet the same loading wheel within the "apps" tap results in an error. My best guess is that some internal link within the app is corrupted, leading to a source on a server that can not be reached.
    UPDATE
    I clean uninstalled adobe creative cloud as discribed in the article you provided (using the cleaner tool) and even uninstalled the browser plugin. After downloading and reinstalling creative cloud the problem however remains the same. "Apps" tap still shows the same problem. "Home" tap now displays the following:

  • Looking for a simple, standalone desktop app for web stats

    Well, I see they've changed the forums here again. SIGH.
    Anyway, a certain web host has eliminated AWStats from it's shared hosting. So I used Webmaster Tools. And now they've changed, and no longer display the simple visitors and hits. Google Analytics is way too complex for what I need, as are many of the stats programs I've looked into.
    I can download the daily Apache log files, that's no problem. Just looking for a small standalone program to import these and show the data like AWStats.  Any suggestions? The only other options would be to go to a different web host. Not a big deal overall, but I would rather not deal with the hassle, especially the migrating the database.

    Not sure of standalone 'desktop' apps. But check out http://www.openwebanalytics.com/ and Web Analytics in Real Time | Clicky  - they're both very intuitive and easy to use with a lot more simplified stats than Google Analytics.

  • My iPad no longer appears in the iTunes desktop app, so I can't sync or transfer files?, my iPad no longer appears in the iTunes desktop app, so I can'y sync or transfer files?

    My iPad no longer appears in the iTunes desktop app, so I can't sync or transfer files?
    I also have an iPod Touch. It appears in iTunes but willnot sync... "unknown error 1723"
    This is a recent problem. Everything was fine initially, and I don't think that I've done anything to change my setup.
    ...Charles

    iPad not appearing in iTunes
    http://www.apple.com/support/ipad/assistant/itunes/
    iOS: Device not recognized in iTunes for Mac OS X
    http://support.apple.com/kb/TS1591
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    iTunes for Windows: iTunes can’t contact the iPhone, iPad, or iPod software update server
    http://support.apple.com/kb/ts1814
    iTunes for Windows: Device Sync Tests
    http://support.apple.com/kb/HT4235
    IOS: Syncing with iTunes
    http://support.apple.com/kb/HT1386
    Apple - Support - iPad - Syncing
    http://www.apple.com/support/ipad/syncing/
    iTunes 10.5 and later: Troubleshooting iTunes Wi-Fi Syncing
    http://support.apple.com/kb/ts4062
    iOS: “Not enough free space” alert when trying to sync
    http://support.apple.com/kb/ts1503
    You may need to delete iTunes on your computer and then reinstall.
    How To Completely Uninstall and Remove All Traces of iTunes
    http://zardozz.com/zz/2008/04/how-to-completely-uninstall-and-remove-all-traces- of-itunes.html/
     Cheers, Tom

  • Desktop app re-downloads installers without retrying on any failure

    [Bug report/feature request]
    The Creative Cloud desktop app on PC has a bad habit of downloading installers from scratch, without retrying an installation, when anything fails -- even if it's a minor connection problem after the installer has finished downloading.
    This is wasting my monthly download quota with my ISP!
    Here's an example of what's happened most recently:
    Tell Creative Cloud desktop app to download the new version of Photoshop
    Photoshop downloads (progress goes past 50%, at which point the desktop app will have downloaded the installer and initialised it)
    Installer initialises
    Desktop app reports a connection error to the adobe servers
    Desktop app starts downloading the installer from scratch, with no option to relaunch the installer
    What should happen:
    Installer downloads
    Any failure launching the installer? Ask if the user would like to try the installation again or download from scratch

    I tried to report the same Feature Request for the Creative Cloud desktop app (in Windows) but this applicaiton does nto exist in the drop-down menu.
    It is very frustrating for files (many that are greater than 1GB) to have to be re-downloaded when the internet connection fails, even momentarily.  I'm a brand new Creative Cloud subscriber and this is not making me a happy customer.
    The Creative Cloud desktop app needs to be able to handle interruptions in connection.

  • Error 201; CC desktop app constantly logged out, won't redownload

    Running CC on Windows 7, 64bit. Have run into the "Please log in/You are now logged out" loop before, so uninstalled the CC desktop app, renamed the OOBE file to OOBE_OLD, and attempted to re-download and re-install the CC app. This worked last time, but today every time I attempt to download, it gives me error code 201 and tells me to seek help.
    There does not appear to be anything pertinent to this issue on the forums already. Any help would be appreciated.

    Hi LawnSnark ,
    Welcome to Adobe Forums.
    Error 201 indicates that the download of the installation files was unable to be resumed successfully or it can be lack of sufficient permissions as well.
    Please create a new Administrator user account , Download Creative Cloud desktop app in new account and sign in.
    Please reply for any assistance.
    Thanks

  • Error Code 201 and 213 when trying to install any Adobe application / Update my Creative Cloud Desktop App. Have tried troubleshooting with Online Chat Agents, no luck.

    I have been trying for 2 days now to get this resolved.
    Computer hashard wired internet connection, running Windows 7 Home Premium. No other issues with downloading or uploading from any other sites or programs. No other network issues reported on other computers.
    It started when I went to install Lightroom through my Creative Cloud. It prompted me to update my Creative Cloud Desktop App, which I went to do and then promptly got Error Code 201. I restarted my Creative Cloud and then skipped the update, hoping it was just an issue with that specific download. I clicked to install Lightroom and the same thing happened, Error code 201.
    I restarted my machine, and tried again. Same issue.
    I contacted Support. They had me go in and change a bunch of folder names to and add "old" to the end of them and then had me try using the Adobe Cleaner tool, which did not work. He had me go in and change some internet settings, still nothing. Same issues as before, only now with all the renaming of things I cannot even open programs I had previously been able to open like Photoshop.
    He instructed me to reinstall the CC Desktop App because the Cleaner tool was not recognizing that it existed anymore (probably something to do with renaming files.. just saying) and now I get the 201 Error when I try to reinstall the CC Desktop App.
    I ran out of time and had to stop after being on with them for over an hour.
    Today I contact back and was instructed to create a new user account on my computer and try downloading and installing the application in the new user. Same errors. 213 at first, restarted my computer and then got Error Code 201 again.
    I am getting really frustrated and really behind on my work. Any information someone could give me would be greatly appreciated. Currently waiting for a chat person to be available again.
    Thank you for your time and assistance.

    Meowia for Error 201 please see Error downloading Creative Cloud applications - http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html.  Error 213 indicates there was problem locating the update or an incorrect URL.  The troubleshooting steps are still the same as both errors are related to failure of the current network connection.

  • ERROR MESSAGE: "Photoshop is a desktop app so you'll want to download it from your computer."

    I just sigend up for Adobe Creative Cloud and I'm trying to install Photo Shop onto my desktop computer.  When I click the download button I receive an error message saying "Photoshop is a desktop app so you'll want to download it from your computer."  I cannot move forward with the download.  Any advice on how to troubleshoot this problem?
    Thanks.

    In my case it's Illustrator and I'm trying to reinstall it. Clearing the cache and using another browser were no help. When I use IE instead of Chrome, an authentication dialog opens to ask permission for CC Desktop to launch, but when I "Allow" it, all that happens is that the CC app opens and gives no indication of a dowload or installation taking place.
    I've always been a strong advocate of CC and was one of the earliest adopters (May 2012), but this is the end of the love affair. I need this fixed immediately. I have work to do. If I had a set-up file sitting on my computer or a disk, I would have no problem right now.

  • Repeatedly receive error message from CC desktop app

    Download Error
    The Creative Cloud installation is no longer functioning, please uninstall and download again from https://creative.adobe.com/products/creative-cloud
    I seem to get this message about once every week or two.

    Hi Mark,
    I think Creative cloud desktop app is currepted. Please go the below location rename OOBE folder and reinstall Adobe creative cloud desktop app.
    WIN: C:\Users\username\AppData\Local\Adobe\OOBE
    MAC: Go>Go to folder>type "~/library" >Application support>Adobe>OOBE
    Let us know if it works.
    Regards,
    Ashish

  • CC apps only have try button in Creative Cloud desktop app

    I received a free 1 year membership because i attended the Adobe Max Conference. I activated the membership in May 2013 and when I go to my profile at adobe.com it says the creative cloud membership is active until May 2014.
    I updated my Creative Cloud desktop app yesterday to download the CC apps and did not have any problems or get any errors. All my CS6 programs are listed in the app along with the CC programs but the CC programs have a try button, not install button. Do I need to re-enter my creative cloud activation code again somewhere else so the programs I download are not trial versions.
    I'm using OS10.8.4

    Jodi I am showing 4 successful activation requests from yesterday.  If you are continuing to experience difficulties then I would recommend contacting our support team.  For the best assistance, I recommend our chat support at http://adobe.ly/yxj0t6.  Our chat representatives can provide a personalized experience to resolve the issue you have described.

  • "Download Error" message in desktop app

    Had an issue with updated payment info not taking a little while back. Found out when the desktop app gave me the "download error" message and to contact customer service. Got the billing info squared away but the download error message I'm getting is still all I can get on the desktop app.
    I've tried signing out and signing back in, uninstalling the desktop app and reinstalling and still no joy. Anyone else having this issue? Or any insight as to what else I can try?
    Thanks

    What browser, and have you tried with your firewall temporarily disabled?
    Link for Download & Install & Setup & Activation problems may help
    -Chat http://www.adobe.com/support/download-install/supportinfo/
    OR
    -Comodo Security kills download http://forums.adobe.com/thread/1460361?tstart=0
    -http://helpx.adobe.com/creative-cloud/kb/error-downloading-cc-apps.html
    -http://forums.adobe.com/community/download_install_setup
    -http://helpx.adobe.com/creative-cloud/kb/troubleshoot-cc-installation-download.html
    -http://helpx.adobe.com/x-productkb/global/errors-or-unexpected-behavior-websites.html
    -http://helpx.adobe.com/creative-cloud/kb/unknown-server-error-launching-cc.html
    -Server won't connect https://forums.adobe.com/thread/1233088

  • Error code 50 CC desktop app install

    I tried to update the creative cloud desktop app and it has now disappeared, I tried to re-install the app but it failed with "error code 50". I searched this error code and followed the link in the forum replies http://helpx.adobe.com/creative-cloud/kb/failed-install-creative-cloud-desktop.html, this relates to error code 1. nevertheless I ran the cleaner tool and it completed successfully. i again tried to reinstall CC app for desktop and again got error code 50. Need this sorted asap!

    Sheenag99555967 did you also rename the OOBE folder after running the CC Cleaner Tool?  What operating system are you using?  What type of environment is this computer located in?

Maybe you are looking for

  • Mail attachments to windows users

    when iI send mail with attachments to Windows users, they can't click on the attachment to view it, they can only download the file. I am sending the mail with windows friendly attchments selected. Any ideas on how I can fix this??

  • How to change the Server email sender's name

    We send email alerts from B1, but when they come from the system they go out with the return address of the email placed in the company details e-mail adress. This is OK but the Name that goes to the recipient says 'Server', Is there any way to chang

  • I cannot open my world on my bb app world

    whenever i open the my world in my bb app world it says "there is an issue with the current session. please log in to continue. error id: 30702". I did the deletion of my bb app world and installing it again but its all the same...

  • Conflict Resolver trying to resolve conflicts from 2004

    It's irritating..... having used Entourage and iCal since 2004, now in trying to sync with 3g, I am getting this pop up that asks me to resolve conflicts dating back in 2004. Is there an option where I can ask it to ignore retroactive dates? My only

  • Error when importing to iPhoto

    Everything on my iPhone has been working fine, including importing photos to iPhone. Suddenly yesterday, it just won't import any new pictures. When I click on Import, it immediately says "Finishing Import" and I get an error message that says " "The