wood burning stoves 2.0*
The moose likes JSP and the fly likes jsp javascript integration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "jsp javascript integration" Watch "jsp javascript integration" New topic
Author

jsp javascript integration

samart mateo
Ranch Hand

Joined: Feb 06, 2006
Posts: 37
hello,

i would like to call javascript from jsp. For example, i have a javascript function:

======================================================
function block() {
var user = document.forms.login.user;
parent.location.href = "block.jsp?user="+user;
}
======================================================

that i would like to call from:

======================================================
if (cek==true) {
con.close();
//call javascript here
// or maybe a scripting that could change iframe parent
// page from jsp here using "response.sendRedirect
// ("block.jsp?user"+user);"
}

else {
String sqlIns = "update log set type = 'ada' where user = '"+userNameReal+"' and loginName = '"+userNameSess+"'";
int rowsAffected1 = stmt.executeUpdate(sqlIns);
}
======================================================

how is that possible? can anybody help me?

or maybe can someone tell me how to change iframe parent page from jsp scripting?

Thank you very much

[ February 06, 2006: Message edited by: samart mateo ]
[ February 06, 2006: Message edited by: samart mateo ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
JSP is a server-side technology, on the other hand JavaScript runs on client-side.

Edited

You can move your condition block completely to JavaScript and then do a redirect.

PS: Moreover, writing SQL queries in JSP page is not considered good. You can move it to some other plain normal java class.
[ February 06, 2006: Message edited by: Adeel Ansari ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

Perhaps this article can help clear up your misconceptions.
[ February 06, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
samart mateo
Ranch Hand

Joined: Feb 06, 2006
Posts: 37
Originally posted by Adeel Ansari:
JSP is a server-side technology, on the other hand JavaScript runs on client-side.

Edited

You can move your condition block completely to JavaScript and then do a redirect.

PS: Moreover, writing SQL queries in JSP page is not considered good. You can move it to some other plain normal java class.

[ February 06, 2006: Message edited by: Adeel Ansari ]



I'm a newbie to JSP technology. Could you gimme an example on how to write SQL queries in some plain normal java class? Eg: How to authenticate an authorized user during logging in.

TQ
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61315
    
  66

samart, it's best not to "gang up" multiple questions in one topic. Let's leave this one to deal with your Javascript issue (did you read the article I linked to?)

I'd suggest posting your database question in the JDBC forum.

Authorized user tracking is best performed with servlet filters. I'd search the Servlets forum for this topic, and then post a question there if you do not find enough information to get you going.
samart mateo
Ranch Hand

Joined: Feb 06, 2006
Posts: 37
I did..and thank you for your help..
 
GeeCON Prague 2014
 
subject: jsp javascript integration