aspose file tools*
The moose likes JSP and the fly likes invalid character constant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "invalid character constant" Watch "invalid character constant" New topic
Author

invalid character constant

Matthew Turner
Greenhorn

Joined: Sep 02, 2004
Posts: 4
hi guys i am trying to use string.replace in my jsp to convert a path name eg. s:\hi\hi\hi.jpg to s:/hi/hi/hi.jpg.

this is my code,

finishedURL = fileName.replace( '\' , '/');


but sadly tomcat says,

org.apache.jasper.JasperException: Unable to compile class for JSPS:\tomcat\work\localhost_8080\_0002fmapCreate_0002ejspmapCreate_jsp_37.java:160: Invalid character constant.
finishedURL = fileName.replace( '\' , '/');
^
S:\tomcat\work\localhost_8080\_0002fmapCreate_0002ejspmapCreate_jsp_37.java:160: Invalid character constant.
finishedURL = fileName.replace( '\' , '/');
^
S:\tomcat\work\localhost_8080\_0002fmapCreate_0002ejspmapCreate_jsp_37.java:160: ')' expected.
finishedURL = fileName.replace( '\' , '/');
^

i am using the java api but obviously this is not the way to do it, any help you could give would be great.
Thanks,
Matt T
Preetham Chandrasekhar
Ranch Hand

Joined: Nov 05, 2003
Posts: 98
put the value in <variable_name>.replace() in double quotes as <variable_name>.replace("\","/"); i am guessing that should work


"In theory, there is no difference between theory and practice. But, in practice, there is."<br /> - Jan L.A. van de Snepscheut
Matthew Turner
Greenhorn

Joined: Sep 02, 2004
Posts: 4
yeah already tried that, but the parameters are characters not strings, actually i think it has something to do with the / character but i am not sure what?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
The backslash is the Java string escape character - '\' is a single quote opening a character constant, followed by the (escaped) character which is a single quote, with no following terminator thereby invalid. I think you meant '\\'.

- Peter
Matthew Turner
Greenhorn

Joined: Sep 02, 2004
Posts: 4
yeah works a treat, thanks for that.

cheers,
matt
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: invalid character constant
 
Similar Threads
Problem integrating Input box with JSP
Internal Servlet Error with JSP + Tomcat 3.2.3
JSP unable to compile class error
Class not found
I have no idea!!!! Help.