Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6935103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:03:30+00:00 2026-05-27T12:03:30+00:00

I have a rather curious scenario, which I am sure that the immense talent

  • 0

I have a rather curious scenario, which I am sure that the immense talent browsing through the questions here at stackoverflow will have very little trouble helping me out.

I have a project in Java – which pretty much does something with taking a file and uploading it in an imaging system. The code works in a way that given the path of the file, it takes it and uploads to the system I want it (this includes a lot of business-specific logic which serves no purpose to be disclosed).

Now, I would like to have an HTML page with a FILE input, that takes a file and then CALLS the code that I wrote which will do the job of taking the file and uploading it to the system.

This means that I have to migrate my Java project into something that can be “callable”.

There are a lot of third party jar files that help my code run.

  1. First scenario would be to somehow make the code into a scriptlet – all the other code can be compiled into a jar. I hate having a jsp that does the deal, but just to get it to a stage where it is working, I would like to entertain this option.
    My question now is where do the jar files go?
    This will be running in Apache Tomcat, so I guess I just place the jars in the lib directory and restart Tomcat and that should do the deal? Is there any classpath file that needs to be modified to make the Tomcat server be aware of the new jar files?

  2. Second scenario would be to have a servlet, and then the jars go in the WEB-INF directory? Please somebody guide me with this one.

What do you think would be the best way to “migrate” my Java code that does the business logic to something that can be called from an html page?
What would be the equivalent of a code-behind?

Thank you very much in advance and hope you can elucidate this matter for me a little bit.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:03:31+00:00Added an answer on May 27, 2026 at 12:03 pm

    This is actually a pretty standard scenario, and there are tons of approaches you can take depending on how scalable you want this service to be, how secure, etc. I’ll start with the approach that requires the least amount of work on your end:

    1. Create a JSP as you mentioned with the file input.
    2. Create a servlet the simply takes the uploaded file (Tomcat will store it in a temporary folder, you may want to move it first) and gets the path.
    3. Have your servlet invoke your existing Java code through a ProcessBuilder and pass the path to it as a command-line argument. Wait for it to complete.
    4. Delete the temp file as necessary.

    A more thorough approach will involve having your servlet directly call the backend Java code. If you already have an interface you can call then you can put the jar file into your webapp’s WEB-INF/lib folder and your servlet will be able to reference the classes in the jar file so you can call whatever class you need to directly. If this process is going to be time consuming then you do not want to hold up the servlet, and consequently the request, so it’s good practice to hand it off to an asynchronous thread that will take care of doing whatever needs to be done with the file and cleaning up afterwards.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rather curious problem. I have a view that I'm animating with
I have rather large project that uses ICU regex classes. Basically it might run
I have some rather odd behavior in my D program that I've narrowed down
I have a rather large text corpus, of which I would like to check
I have a rather enormous project in which I'm trying to retrofit in-memory data.
I have a rather large SQL file which starts with the byte order marker
I have a rather huge query that is needed in several stored procedures, and
I have a, what seems to be, rather common scenario I'm trying to work
I have a rather curious problem, using the XElement load method to load in
Have a (rather complex) app that works fine on iOS 4 but fails on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.