Jump to content
xisto Community
masugidsk8r

Concerns On Ajax With Java

Recommended Posts

Source article from Sun: http://www.oracle.com/technetwork/java/index.html

Well, from this article, it shows that Ajax can be achieved with Java using Java Servlets or JSP's.

For those who don't know what AJAX is, it's an object in Javascript technology that allows for instant communication between client-side and server-side. It's like changing a page's content without having to reload the whole page.

Let's move on... Now when I looked at the JSP source code, the servlet's function was to simply validate a text and send back a response in XML format. That's basically all what it needed to do.

It required a lot of lines to obtain the information from the HTTP Request, connect to a database, validate the object passed through the URI and send back a response in XML.

After looking at the code and understanding it, I thought to myself, "Why not do this in PHP? Can't I achieve the same thing in PHP with a lot less lines!?"

As far as I know, I believe so. If PHP can obtain a variable using $_GET or $_POST method, connect to database using MySQL, validate it, and send back a response in XML-format--with even less lines than JSP, why not do it?

My concern is, can PHP replace the JSP source code found in that article? Wouldn't I be able to achieve the same result with PHP?

---

PHP is a great OOP language and it's a powerful language. I think I can stay using PHP with AJAX over Java. If there are those who would like to disagree, please tell me the advantage of using Java Servlets (JSP).

Thank you.

Share this post


Link to post
Share on other sites

I was just reading this article when I saw your post on the forum. I think you can do it with the php in fact I assume it is not problem at all (I won't try but there shouldn't be any obstacles in your way). However your price would be speed because the emphasizes here is on the speed and the fact that you don't have to reload page once again to change its content and that is true however you would have to load page if you are about to change it with php. Or at least specific part of page as like frame or pop up window. This is my oppinion I would like to hear what do you think is it valid I mean the speed sacrifice, against this implementation. Because they presented really nice merge of technologies over there.

Share this post


Link to post
Share on other sites

Hitman, what I'm trying to say is that my PHP file would replace JSP. I can still achieve AJAX because it's Javascript. Instead of connecting the AJAX object to a JSP, I connect it to a PHP page and achieve the same result. I've tried it and I didn't have to reload the page.The PHP script would be back-end not front-end that's why the user won't have to reload the page (thanks to AJAX).A better combination (in my opinion) is: XHTML/Javascript(AJAX)/PHP instead of: XHTML/Javascript(AJAX)/JSP(JAVA)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.