Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Ajax + Java

  • 08-08-2007 4:34pm
    #1
    Registered Users, Registered Users 2 Posts: 1,019 ✭✭✭


    Hi Folks,

    I was wondering if anyone knew of any good tutorials or walkthroughs for n00bs in the world of AJAX and Java. Im looking for something a little structured that would walk me through maybe the setup of a development environment, creation of a web app and some AJAX with simple java handling at the backend.

    Ive been looking on the web but all the tutorials seem to be very bitty so they are very basic or at a much higher-level for solving a particular issue or demonstrating how something is done. Im looking for something of a compromise between these as I've have programmed in Javascript and Java before (although my knowledge of web apps etc is a little vague). Right now its not the coding etc thats disconcerting but right now the information feels very dispirit and vagaue.

    PDD


Comments

  • Closed Accounts Posts: 2,279 ✭✭✭DemonOfTheFall


    PHP, ASP, what ?

    For the ASP.NET way of doing things http://www.asp.net/learn/ will give you a quick idea to get you started on most things.


  • Registered Users, Registered Users 2 Posts: 4,276 ✭✭✭damnyanks


    What exactly are you using with the java mon ?

    What framework ? Would you not be better off using something like asp.net, ruby on rails, php ?


  • Registered Users, Registered Users 2 Posts: 1,019 ✭✭✭PDD


    Hi Guys,

    Cheers for the feedback but as Ive mentioned I would prefer to code in Java on the backend as I know it already and use it in work. I have used PHP and ASP in the past and wIm more comfortable with Java.

    Dave


  • Closed Accounts Posts: 1,106 ✭✭✭MoominPapa


    I can't figure out from your posts if you would have come across Netbeans, plenty of ajax demos on the site, not that I've used them - I've just started intranet development and netbeans + tomcat gives me everything I need and much more


  • Registered Users, Registered Users 2 Posts: 378 ✭✭sicruise


    It doesn't matter what you code with on the backend...

    If you are using AJAX correctly it will be an XML post... just parse the XML... do what you want with the info and return a response. In java you could write a simple servlet just writing XML to the output stream with the content type set to "text/xml".


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,127 ✭✭✭smcelhinney


    The netbeans AJAX module only comes with the Visual Web developer pack, and to be honest, if you're not a dab hand at Visual Web then it will take you forever to get the hang of this.

    Start with something simple. Create a servlet/jsp to display information from a database, like a table. Put this in an external JS:
    function stateChanged() 
    { 
    	if (xmlHttp.readyState==4)
    	{ 
    	document.getElementById("targetTag").innerHTML=xmlHttp.responseText;
    	//document.getElementById("retrieve").disabled=false;
    	}
    }
    
    function GetXmlHttpObject()
    {
    	var xmlHttp=null;
    	try {
    	// Firefox, Opera 8.0+, Safari
    	xmlHttp=new XMLHttpRequest();
    	} catch (e) {
    	// Internet Explorer
    		try {
    			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    		}
    	}
    	return xmlHttp;
    }
    
    function showDatabaseOutput(id){
    	xmlHttp=GetXmlHttpObject();
    	if (xmlHttp==null) 	{
    		alert ("Your browser does not support AJAX!");
    		return;
    	} 
    	var url="ajax_getDBOutput.jsp";
    	url=url+"?id="+id;
    	url=url+"&sid="+Math.random();
    	document.getElementById("targetTag").innerHTML="Loading db output...";
    	xmlHttp.onreadystatechange = stateChanged;
    	xmlHttp.open("GET", url, true);
    	xmlHttp.send(null);
    }
    

    Then you can use this code to display it to a target element:
    <select name="id" onchange="showDatabaseOutput(this.value)">
    <option ="1">Ford</option>
    <option ="2">Porsche</option>
    ...
    </select>
    <div id="targetTag"></div>
    

    And thats the most simplistic form of Ajax that I've ever done!! : )

    Seriously though, you only need a few controller javascript functions, and then create a load of view components in JSP or servlets. Also, I would suggest that you remove as much markup from the JSP/Servlet as possible. If, and where, possible, you could use some sort of XSL transformation to ensure that you have valid XHTML markup, essential for ALL Ajax development.

    Hope this helps, best of luck.


  • Registered Users, Registered Users 2 Posts: 2,325 ✭✭✭Q_Ball


    GWT maybe?


  • Registered Users, Registered Users 2 Posts: 1,019 ✭✭✭PDD


    Cheers for the info guys


Advertisement