invoke java compiler within tomcats

is it possible to call the java compiler from within a jsp page within tomcats.  i have a program that generates random java code and i would like to compile this code and write the results to a text file?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Theoretically yes (since your jsps themselves need to be compiled) but make sure you have security permissions to do so and ensure that tools.jar is in the classpath
Mick BarryJava DeveloperCommented:
following articles covers what u need to do

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Mayank SAssociate Director - Product EngineeringCommented:
>> i have a program that generates random java code and i would like to compile this code

Does the code keep changing? If not, then why do you want to compile it? You can simply run it/ call it and get the random numbers which it generates.
donnaeAuthor Commented:
the reason i want this code to be compiled is that this is a quiz and the user will be asked a question and asked to pick an answer therefore the code must be compiled before hand to know what the result will be
Mayank SAssociate Director - Product EngineeringCommented:
Ideally the questions and answers should be stored somewhere else like a database/ file and the code just pick up a question randomly from there if that is what is required.
donnaeAuthor Commented:
The code is generated randomly from an xml file therefore i do not know what the result will be.
Mayank SAssociate Director - Product EngineeringCommented:
And the code contains questions/ answers? They should be in the XML or database I guess.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.