could anyone solve this error ??? it occurs in the below code
for (int i = supportedLocales.length-1; i >= 0; i--)
<a class ="langChangeOn"
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 101 in the jsp file: /home1.jsp
The method print(boolean) in the type JspWriter is not applicable for the arguments (void)
99: <a class ="langChangeOn"
101: <%= session.setAttribute("userId", supportedLocales[i].toString() )%> ; document.repost.submit();">
102: <%= supportedLocales[i].getDisplayLanguage(supportedLocales[i])%>
I am not quite clear about your java script! but I can give you a hint regarding error that you have got !
hint : HttpSession#setAttribute method dont return anything !
Note: If possible Please avoid scriptlet in your jsp. because now it is difficult to debug right? and use code tag while posting your code.
And Welcome to JavaRanch :)
Joined: Oct 30, 2011
i will explain the code so you can support me more
the application support two languages (english and arabic)
Locale supportedLocales = I18nUtil.getSupportedLocales();
there are two elements in the supported locales: 'en' and 'ar'
the output of the for loop are two links one for arabic language and the other for english language
when the user choose english language by cliking the english link i need the session varaible userId to have the value 'en'
when the user choose arabic language by cliking the arabic link i need the session varaible userId to have the value 'ar'
i will use the session variable userId later to identify which CSS will be used based on the selected language .
please support me to correct the error in the code and if you want more explanation i will be glad lo explain more :)
hint:the code is running correctly until i put this sentence<%= session.setAttribute("userId",supportedLocales[i].toString())%> then the error is occured
I answer your question already! set the selected language on server side! more over, scriptlet executed long before your client code. why cant you use simple href and append the value? or onclick submit form.
regarding your error: you cant display nothing/void. for example try below code
Bear Bibeault wrote:Why are scriptlets and scriptlet expressions still being used? They've been discredited since the introduction of JSP 2 almost 10 years ago!
Joined: Oct 30, 2011
Thanks for reply :) .actually this is an open source software called dspace for digital library I try to do simple customization for it to meet my needs
this website is do the same what I need http://repository.ksu.edu.sa/jspui/ when you access the website there are two links for the languages and when you choose one of them the body direction changes from left to right or from right to left accordinary
I try to do the same customization in my website and I notice that they use different style sheet for each language
below is the original code before any customization ,you will notice that I couldn't use href because there is no destination and also there is no action in the submited form :(
and I am very beginner in java coding
does anyone knows how to do that ?
and this is the code of the header.jsp
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: The method print(boolean) in the type JspWriter is not applicable for the arguments(void)