my dog learned polymorphism*
The moose likes JSP and the fly likes The method print(boolean) in the type JspWriter is not applicable for the arguments(void) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "The method print(boolean) in the type JspWriter is not applicable for the arguments(void)" Watch "The method print(boolean) in the type JspWriter is not applicable for the arguments(void)" New topic
Author

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

loleta yahyan
Greenhorn

Joined: Oct 30, 2011
Posts: 3
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: <%
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 30, 2011
Posts: 3
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

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Jan 28, 2008
Posts: 5575

and you can think <%= %> as System.out.println()
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

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!


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Oct 30, 2011
Posts: 3
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
 
Don't get me started about those stupid light bulbs.
 
subject: The method print(boolean) in the type JspWriter is not applicable for the arguments(void)