473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to send a JS variable within a scriptlet tag to call a Java method?

Please find below my Java script method in which i call a java method to fetch a locale specific error message
Expand|Select|Wrap|Line Numbers
  1. alert(<%=Msgs.getMessages("MessageResources", "errors.textNotLatin");
I can get the locale through this in my script
Expand|Select|Wrap|Line Numbers
  1. var locale = document.UserForm.preferredLanguage.value;
I need to send this 'locale' value along with the alert message
For eg it should read as below for locale germany
Expand|Select|Wrap|Line Numbers
  1. alert(<%=Msgs.getMessages("MessageResources_de", "errors.textNotLatin"); 
or
Expand|Select|Wrap|Line Numbers
  1. alert(<%=Msgs.getMessages("MessageResources", "errors.textNotLatin", <%=locale%>);
I am unable to send the locale variable as a third parameter or append it to the MessageResources string directly. Could someone please help?
Jun 14 '10 #1
5 4670
RamananKalirajan
608 512MB
If you are working in a JSP, why cant you set those variables in request or session to get that value in Java function.

Thanks and Regards
Ramanan Kalirajan
Jun 14 '10 #2
I would not be submitting the form. This is for validating the input and dynamically displaying the error message in a locale specific language.
Jun 14 '10 #3
RamananKalirajan
608 512MB
Try like this
Expand|Select|Wrap|Line Numbers
  1. <%
  2. String str = '"MessageResources","errors.textNotLatin","'+
  3. %>
  4. document.write(locale);
  5. <%+"';%>
  6. alert(<%=Msgs.getMessages(str)%>);
Thanks and Regards
Ramanan Kalirajan
Jun 15 '10 #4
I still get a compilation error. Its the single quotes.
Will the java variable str be recognized by the alert which is JS?
Jun 15 '10 #5
RamananKalirajan
608 512MB
then use escape sequencing character for double quotes " \" "

Thanks and Regards
Ramanan Kalirajan
Jun 15 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Dave Kuhlman | last post by:
Is JPE (the Python Java Extension) being used widely/actively? I tried to build it (with Python 2.3.4, j2se 1.4 on Debian GNU/Linux) and had quite a bit of trouble. And, then, the samples did...
6
by: Robbie Baldock | last post by:
Hi - I'm a bit of a newbie to the world of XSLTs but am trying to call a Java method on a parameter passed into an XSLT but am having problems. I've stripped the XSLT down to its bare bones: ...
2
by: Neil Cherry | last post by:
I've done a fair amount of searching on this subject and I can call my Java methods with Javascript if I use the <applet></applet> tags but when I switch over to <object></object> tags I'm not...
13
by: jac | last post by:
Hae, I have a windows form with a ComboBox an other things. On that combobox I have an eventhandler on de selectedindexchanged. But somewhere in my code want to do excecute the same code that...
4
by: Mariame | last post by:
Hi Everyone i have a web page that i write in it the connection string of the database & i declare the session i want when the user open any page & doesent start with the index page , i dont...
2
by: mhust6 | last post by:
I am trying to call a java method from within my Javascript, but cannot seem to get it to work. All the examples I have found online and in the forums are using Java applets. I have a method that...
11
by: BigZero | last post by:
Hello, can i call Java method.That is java code from php,here what i m looking for i have class called DB in this class all the DB related things ,like DB connection DB insert,DB read etc...
6
by: Christopher | last post by:
Its been awhile and I am rusty. Can the constructor of my class call another method in the same class if that other method does not change any member data? I want to simply have a seperate...
1
by: manjava | last post by:
hello, i want to test my service web i write this class to call my method appel:import projetd.MagasinServicesStub.ListeMagasinProcheDeResponse; import java.rmi.RemoteException; public class...
2
by: swamyvnvs | last post by:
HI friends, i have a problem when i call a java method from php code, i saw php.net site ifollow all thr steps , but i got the classNotFoundExceptions. my code is like this JavaClass ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.