We would like to generate simple mathematical formulas on the fly (e.g. $\sin^2 \theta$). The above function seems to be a MathJaX representation. Most of the solutions depend on writing mathematical equations using MathML or Latex or jsMath or MathJaX. I am assuming MathJaX would be the right solution to use if you are planning write these equations right now and most of these solutions get embedded as javascript directly.
Is there a way to generate these equations on the server side using a language like Java assuming the application logic provides a mechanism to embed them in the HTML. What kind of solutions are available if we have to go down this path.
I am a complete novice on this subject, looking for inputs so that we choose the right solution.