Can I connect JSP to C++ code?

Posted on 2004-11-19
Last Modified: 2010-04-01
I want to create a client/server application which is web based, I want to write my server in C++ because I have to make Win32 calls and it's just easier to do it in C++. Could anyone tell me what language I should use for the web based (client) side? The language that I would be more familar with is Java so I was hoping to use something like JSP, would this be possible? If so how could I connect the client and server (sockets?) ? and if it's not possible to use JSP could someone suggest another way.
Question by:Dcom4CIT
    LVL 35

    Expert Comment

    So you want to have 2 servers?

    C++ server  -->  Web Server -->  Client browser


    If your C++ application (server?) is a DLL, then you can call it using JNI:

    Of course, you could skip the C++ layer, and just write something that uses a library like JaWin:

    JaWin is a library that helps you call Win32 methods from java (via JNI)
    LVL 35

    Expert Comment

    So you could just have JSPs which call Jawin (is what I meant by all the above waffle) ;-)
    LVL 35

    Expert Comment


    is a good list of other alternatives to Jawin...some free, some commercial

    Author Comment

    I'll go into my project in a bit more detail to explain what I have to do. It's basically a project for college dealing with Storage Provision for hosts from EMC's Symmetrix, I'll be using some internal EMC API calls along with Win32 calls, the two of these type of calls are the core of the project and would be better done in C++. I would like to make this a web base application and basically don't know what technologies I could/should use.

    One way I'm investigating is to have a C++ CGI on a webserver (Apache) which would do the core of the work and the data sent out as XML files (using REST), I was told that this would make the project language independant, so I could use JSP, PHP or whatever for the web frontend.

    So could you tell me if this is the way to go or is there a better way? If there's not a better way then is there any useful wesites or books on this area?

    And if there is a better way to do this project could you please explain it to me, basically all i want is a C++ program to do the work and have the results on the web.

    I apologise in advance if the above doesn't make sense because it's all very new to me and I don't fully understand it myself.
    LVL 35

    Accepted Solution

    Yeah, that sounds like a good way of doing it in that case :-)

    If you write the C or C++ CGI script so that it takes parameters and outputs XML (as you say), you can then use something like JSPs and Servlets to interrogate this XML and send responses to the user...

    One way to implement all this would be to use the Tomcat webserver as that supports JSPs and Servlets, and CGI.  See this

    For how to enable to CGI bit of tomcat (it should be a commented out block in conf/server.xml of tomcat, which you can uncomment to enable)

    Hope I've helped a bit (at least) I haven't used CGI or C++ for years, I'm more of a java guy these days...

    LVL 35

    Expert Comment

    PS:  Good luck!! :-)

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    JTable - RowFilter & Columns Header. 3 129
    Set up Wildfly 10 8 282
    grep code 4 134
    doubleChar java challenge 7 92
    Great sound, comfort and fit, excellent build quality, versatility, compatibility. These are just some of the many reasons for choosing a headset from Sennheiser.
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now