• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

The method print(boolean) in the type JspWriter is not applicable for the arguments(void)

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
good day

could anyone solve this error ??? it occurs in the below code

for (int i = supportedLocales.length-1; i >= 0; i--)
{
%>
<a class ="langChangeOn"
onclick="javascript:document.repost.locale.value='<%=supportedLocales[i].toString()%>';<%= session.setAttribute("userId",supportedLocales[i].toString())%> ; document.repost.submit();">
<%= supportedLocales[i].getDisplayLanguage(supportedLocales[i])%>
</a>  
<%
}
%>

the error:
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)
98: %>
99: <a class ="langChangeOn"
100: onclick="javascript:document.repost.locale.value='<%=supportedLocales[i].toString()%>';
101: <%= session.setAttribute("userId", supportedLocales[i].toString() )%> ; document.repost.submit();">
102: <%= supportedLocales[i].getDisplayLanguage(supportedLocales[i])%>
103: </a>  
104: <%
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :)
 
loleta yahyan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Mr.Seetharaman
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
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

<edit>enabled smilies</edit>
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and you can think <%= %> as System.out.println()
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Seetharaman Venkatasamy wrote:and you can think <%= %> as System.out.println()


Not correct. A scriptlet expression will emit its output to the response; System.out will emit to the console. They're not at all alike.

But when it comes down to it, this is 2011! Why are scriptlets and scriptlet expressions still being used? They've been discredited since the introduction of JSP 2 almost 10 years ago!
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!


Indeed
 
loleta yahyan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Time is the best teacher, but unfortunately, it kills all of its students - Robin Williams. tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic