Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2007

Tip: Looking for answers? Try searching our database.

run jsp on javascript event

Thread view: 
bbembi_de@lycos.de - 21 Nov 2007 11:04 GMT
Hello everyone,

I am using an javascript table. if I edit a cell I want to write the
new value in the DB with jsp.

How can I do that?

I would like to call a jsp in background if that is possible.
Or are there any other possibilities?

bye juergen
polilop - 21 Nov 2007 11:37 GMT
> Hello everyone,
>
[quoted text clipped - 7 lines]
>
> bye juergen
You can do this with AJAX.
bbembi_de@lycos.de - 21 Nov 2007 11:49 GMT
> <bbembi...@lycos.de> wrote in message
>
[quoted text clipped - 11 lines]
>
> You can do this with AJAX.

Please give me a little example. I am totally new with AJAX.
I use an AJAX component as table: dhtmlxGrid.

bye juergen
Andrew Thompson - 21 Nov 2007 13:27 GMT
>> <bbembi...@lycos.de> wrote in message
>>
[quoted text clipped - 3 lines]
>
>Please give me a little example.

Please state your budget for providing this 'little example'.  

Alternately, you might actually demonstrate some effort
at figuring what polilop was saying, with appropriate use
of your favorite search engine, to *avoid* asking stupid
questions.

Signature

Andrew Thompson
http://www.physci.org/

polilop - 21 Nov 2007 13:43 GMT
>> <bbembi...@lycos.de> wrote in message
>>
[quoted text clipped - 17 lines]
>
> bye juergen

you will need to learn about AJAX before.
looka at http://www.w3schools.com/ajax/default.asp
or at:
http://www.ajaxtutorial.net/index.php/2006/03/08/simple-ajax-functions-snippets/
Allso look at ajax prototype, might be helpful

here is  what i use for simple ajax requests (found it on the web but was
unable to find the page again):
ajaxUpdate( 'display', '/myUpdate.do',
{params:'value='+document.getElementById('myValue').value,async:false,startfunc:'loadingMessage();'
});

elemid=id of element that will receive the return information
url =url of the servlet that will make the update eg. myServletUpdate
options = you put options in{} like this, startfunc is if you need to run a
function before the ajax call.

function ajaxUpdate( elemid, url, options )

{

var params = options.params || "";

var meth = options.meth || "post";

var async = options.mode || true;

var startfunc = options.startfunc || "";

var endfunc = options.endfunc || "";

var errorfunc = options.errorfunc || "";

var req = false;

params = params+"&random="+Math.round(10000*Math.random());

//Enkoding for utf-8 do not use if page allready in utf-8

params=encodeURI(params)

//alert(params);

try {

req = new XMLHttpRequest();

} catch(e1) {

try {

req= new ActiveXObject("Microsoft.XMLHTTP");

} catch(e2) {

try {

req = new ActiveXObject("Msxml2.XMLHTTP");

} catch(e3) {

return false;

}

}

}

if( startfunc != "" )

eval( startfunc );

req.open( meth, url+( params != "" ? "?"+params : "" ), async );

req.setRequestHeader( "Content-Type",
"application/x-www-form-urlencoded;charset=UTF-8" );

req.onreadystatechange =

function()

{

if ( req.readyState == 4 )

{

if ( req.status == 200 )

{

hideMessage();

document.getElementById(elemid).innerHTML = req.responseText;

if( endfunc != "" )

eval( endfunc );

return true;

}

else

{

hideMessage();

if( endfunc != "" )

eval( endfunc );

if( errorfunc != "" )

eval( errorfunc );

return false;

}

}

};

req.send(null);

}

Hope this helps.
Lew - 21 Nov 2007 14:25 GMT
<bbembi...@lycos.de> wrote in message
>>>> I would like to call a jsp [sic] in background if that is possible.
>>>> Or are there any other possibilities?

>>> You can do this with AJAX.
...
> you will need to learn about AJAX before.
> looka at http://www.w3schools.com/ajax/default.asp
> or at:
> http://www.ajaxtutorial.net/index.php/2006/03/08/simple-ajax-functions-snippets/
> Allso look at ajax prototype, might be helpful

You don't "call" a JSP in the same sense that you call a method.  Also, unless
you are creating HTML for display, you shouldn't use a JSP on the server side,
but a servlet coded directly as a Java class.

JSPs are presentation artifacts; they should contain literally no Java
scriptlet.  Java-coded servlets are logic artifacts; they usually should
contain literally no HTML markup.

Signature

Lew

polilop - 21 Nov 2007 20:28 GMT
> <bbembi...@lycos.de> wrote in message
>>>>> I would like to call a jsp [sic] in background if that is possible.
[quoted text clipped - 15 lines]
> scriptlet.  Java-coded servlets are logic artifacts; they usually should
> contain literally no HTML markup.

I agree with your statement, that's why i wrote
"url =url of the servlet that will make the update eg. myServletUpdate"
assuming bbembi_de knows about servlets.
bbembi_de@lycos.de - 22 Nov 2007 12:14 GMT
> > <bbembi...@lycos.de> wrote in message
> >>>>> I would like to call a jsp [sic] in background if that is possible.
[quoted text clipped - 22 lines]
> "url =url of the servlet that will make the update eg. myServletUpdate"
> assumingbbembi_deknows about servlets.

This works just perfect!

Thank you very much! I thought I never solve this.

bye juergen


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.