Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using escape and unescape in Java/Javascript

Status
Not open for further replies.

ob1kanobee

Programmer
Dec 27, 2002
47
US
Hello,

I am trying to incorporate the escape/unescape function written in javascript within a java process page.
It seems simple enough, but I cannot get it to work.

Code:

<script language="javascript">
function doEscape(sFileName) {
if(sFileName != null && sFileName != "") {
return escape(sFileName);
}
</script>

Here's the Java code calling the javascript function. The getAbsolutePath returns me the path and filename being imported. I need for users to be able to upload filenames with ascii and non-ascii characters as well as punctuations, etc.:

<%
sFilenameLocal = fCustomerSat.getAbsolutePath();
sFilenameLocal = %>doEscape(<%=sFilenameLocal%>)<%;
System.out.println("FileName is: " + sFilenameLocal);
%>



I keep getting an "incompatible types" error even though the variable sFilenameLocal is a string variable.

I also tried putting quotes around the java sFilenameLocal variable with basically the same results.


What am I missing here? Any help will be appreciated. TIA



 
> sFilenameLocal = %>doEscape(<%=sFilenameLocal%>)<%;
It seems you assigned client-side string back to server-side variable. It won't do?!...
 

Your best bet is to ask in the Java forum about how to escape strings server-side. I believe it might be something like escapeURL or similar?

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top