Hacker News new | ask | show | jobs
by kp212 5811 days ago
You can do that with a JSP page, and Tomcat. You can use JSP very much like a scripting language (no need to hit a servlet, controller, etc), but obviously it can get a little messy to manage depending how large of app you write.
2 comments

One big problem; if you keep most of the Java code on the servlet side and you throw an exception, the stack trace will give you the line number of the offending code.

OTOH, if you do all that heavy lifting in the JSP side, depending on your choice of server, you get a stack trace...either without a line number, or with a line number of the JSP which was compiled and turned into a Java program on the fly.

And we all know what machine-generated Java looks like, right? Like a big plate of pain with some extra pain on top. Good luck bug-hunting that one.

Not entirely true. On Tomcat 5 and 6, the resulting code is really close to the original, plus lots of out.write().

If the logs show an exception on org.apache.jsp.mypage_jsp._jspService(mypage_jsp.java:NNNN), you can find the generated Java class on TOMCAT_HOME/work/Catalina/localhost/myapp and it's rather straightforward from there.

I do this on a daily basis to maintain a legacy app. Not sexy but, not hard either.

Yeah you are right, lets just forget using jsp without the framework model.
And that's why I thought he was talking about Java webapps in general. I mean, JSTL is pretty useless if that's the way you're going to use JSP. :)