wood burning stoves 2.0*
The moose likes JSP and the fly likes JSP in Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP in Javascript" Watch "JSP in Javascript" New topic
Author

JSP in Javascript

Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Could i use such JSP scriptlets in Javascript.

Following is Javascript code



the above function is to be called during onload()




when i execute the code it shows error. Object Expected or Syntax error
but i am not getting Syntax error in above god
and what is object expected?

Could i use JSP as i used above?


Regards
Azrael Noor
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Firstly, scriptlets? In 2010? Really?

Secondly, did you look at the HTML page that's being sent to the browser? Is the generated JavaScript code valid?

Yes, you can use JSP constructs in JavaScript, but remember that they execute on the server in order to format the code to be sent to the browser, where it will be evaluated.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
Firstly, scriptlets? In 2010? Really?


can't i drive Old Bike, i don't care about average.



Ya The code is working, but the Scriptlet i used inside Javascript is not working

Yes, you can use JSP constructs in JavaScript, but remember that they execute on the server in order to format the code to be sent to the browser, where it will be evaluated.


My computer is localhost.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

/unsubscribes
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
what is that sir?

/unsubscribes?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It means that you're not really paying attention to what he's saying.

And it's way cooler to ride an old bike than to needlessly shoot yourself in the foot... nay, upper torso, by using *very* outdated programming techniques.

If you want to use JSP functionality inside a JavaScript file then it has to be processed by the JSP compiler, which means you either need to change what file extensions are processed by the JSP compiler, or you have to name it .jsp.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi Azrael ,

try this and then that will work I guess,




but still as Bear says it bad practice to use scriptlets in JSP, Instead of it you can use EL.


Thanks,
Shailesh
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
@David

Ya I Understand what he is saying, and i appreciate his saying but i am trying to say that nowdays i am driving old bike and ya may be it is ethically wrong.
but old is gold.

I will surely shift to new in few days.

If you want to use JSP functionality inside a JavaScript file then it has to be processed by the JSP compiler,
which means you either need to change what file extensions are processed by the JSP compiler, or you have to name it .jsp.


i am using javascript inside JSP file and i am using <%%> too still it is not getting value.
Same file contain HTML, DHTML, JAVASCRIPT and JSP.

nowhere i mention that i am using javascript FILE.


@BEAR SIR

don't get angry please.
I am told to use scriptlets thats why i am using.
The demanding party is not in 2010


Shailesh Narkhede

Ya it's bad to use scriptlets.
I am very bad, but sir you also tell me one thing

why ------> (var a = '<%=SessionValue%>';) is not working.
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi,

Could you please tell us what error you are getting? or getting same error as previous?
Azrael Noor
Ranch Hand

Joined: Jul 29, 2010
Posts: 382
i am using net beans

when i write scriptlet it color also changes
so it's first Clue that Scriplet is not running.

Secondly i am getting same message as before.

is it working on your side?
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

Try to do like this:


And at your event


[uaiHebert.com] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

With the addition of quotes around the JS function call parameter.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 806

Try this


EL equivalent

May be this may help you.


Love all, trust a few, do wrong to none.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP in Javascript