File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes JSP and javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "JSP and javascript" Watch "JSP and javascript" New topic

JSP and javascript

Rashmi Gowda

Joined: Dec 04, 2000
Posts: 5
Hi All,
I would like to know if there is a way for adding a javascript 'alert' button in JSP such that the alert button appears on the same JSP page.Right now iam able to get the alert message on a different page. similarly can i add/embed JSP code(i.e, scriptlets/beans) in Javascript??
Any other ideas/suggestions to do the same ?
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Lets remember what Javascript is - a scripting language written into a HTML page and executed on the browser side.
Anything you can create in Javascript on a plain HTML page can also be created on a HTML page written by JSP - the trick is getting the syntax and quote marks escaped properly.
Also remember what JSP is - a language for creating servlets on the server side based on a mix of HTML, special tags, and Java code. Any Java code you "embed in Javascript" will be meaningless on the browser side.

author of:
Renata fonseca
Ranch Hand

Joined: Mar 15, 2002
Posts: 48
Are you sure?
Jesse Beaumont
Ranch Hand

Joined: May 30, 2002
Posts: 43
Technically, JSP is a language, depending on what your definition of language is. The fact that it is then interpreted into Java is of little concern, but the fact that it has to be interpreted surely indicates that an argument exists for it to be denoted a language in its own right. That detail is of little relevance to the above post.
I would, however, add to Bill's post, just to be explicit that JSPs are not restricted to producing HTML (though clearly that is the scope of this thread)
Jesse - with pedantic hat

---<br />Time flies like an arrow,<br />Fruit flies like a banana
I agree. Here's the link:
subject: JSP and javascript
It's not a secret anymore!