in my application I need to prepare a path for XML file inside JSP page. I'm doing someting like this:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
<!DOCTYPE html>
<c:set var="abs_path" value='<%= getServletContext().getRealPath("").replace(" ", "%20").replace("\\", "/") %>' />
But there is a problem, I get the followind exception:
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 6 in the jsp file: /users.jsp
String literal is not properly closed by a double-quote
3: <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
4: <%@ taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x" %>
5: <!DOCTYPE html>
6: <c:set var="abs_path" value='<%= getServletContext().getRealPath("").replace(" ", "%20").replace("\\", "/") %>' />
Apparently it's about this part: .replace("\\", "/")
When I delete it, I don't get this exception.
What's that about? I will be very grateful for any clue.
EDIT:
I use this variable in the following way:
<c:import url="file:/${abs_path}/MyProject/xml/users.xml" var="inputDoc" charEncoding="UTF-8" />
<c:import url="xsl/users_list.xsl"
var="stylesheet" charEncoding="UTF-8" />
<x:transform
xml = "${inputDoc}"
xslt = "${stylesheet}">
</x:transform>