Originally posted by Justin Fox: how do I make it to where the function only happens when the buttion is clicked...
You don't. The Java in the JSP -- which at this stage of the game is a bad habit you should drop asap -- executes on the server long before the HTML page is sent to the browser where a user will get the opportunity to click on a button. You should read this article.
Originally posted by Justin Fox: What good is JSP besides being a server sided language more familiar to java programmers?
JSP is an extremely powerful server-side templating language with all the power of Java behind it. As the view tier of a web application written in Java, you get all the extensibility, scalability and security that the language provides.
I mean PHP or ASP does the same thing.
They're all implementations of the same idea. With JSP, you get the power of Java behind you. Not so much with php.
I can do that with PHP.
Sure, if php is more familiar and works for you, great! I personally found php to be very limiting as soon as a web app goes beyond a page or two.
I guess AJAX is the only way to update stuff client-side "dynamically".
And I got an answer that basically said using java in the jsp file was a no no? I thought jsp stood for java servlet pages...
It does. But just because you can do something, doesn't mean it's a good idea. With JSP 2.0, the Java-powered EL and JSTL provide a much cleaner means of creating dynamic templates than old-fashioned scriptlets.
In a Java web app (at least a well-structured one), the vast majority of the app will not be on the pages (compare that to a php app), but in robust Java classes. The JSP pages end up being just a small facet of the app used to dynamically generate the HTML pages. All the real work goes on "behind the scenes". [ January 11, 2008: Message edited by: Bear Bibeault ]
This article regarding web application structure might be informative.
Joined: Jan 24, 2006
Thanks for the info, I really do appreciate it. Kinda cleared things up for me
But one more thing...
In what instance or senario (in developing a website) would JSP be a better choice for the server-sided script than say PHP or ASP?
In a Java web app (at least a well-structured one), the vast majority of the app will not be on the pages (compare that to a php app),
Are you speaking of an actual Java Applet? Or are you talking about a Java "App" in JSP on the server side?
If it was referring to a Java Applet, how can you compare that to PHP is what I'm getting at.
And using AJAX with JSP would be similar right? just do the "xmlHttp.open(GET,url,true);" and then on the jsp side get the variables in the url, do some kind of calculation and then "out.println(responseText);" right?
Justin Fox [ January 12, 2008: Message edited by: Justin Fox ]
We have some examples in our CodeBarn. See SimpleMVC and SimpleCommand.