Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp javascript integration

 
samart mateo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this article can help clear up your misconceptions.
[ February 06, 2006: Message edited by: Bear Bibeault ]
 
samart mateo
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did..and thank you for your help..
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic