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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to escape strings server-side

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
 
Ask yourself these questions :

1) Does the Java part of a JSP page (within the scriptlet tags) execute on the client, or the server ?

2) Does Javascript exectute on the client or server ?

When you can answer these questions correctly, and understand them, you will be able to answer your own question :)


--------------------------------------------------
Free Database Connection Pooling Software
 
Thanks for the response.
Java executes on the server side and Javascript executes on the client side. Now that I understand what's going on, is there a workable solution for this scenario or a similar function in Java for the escape and unescape functions?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top