Zhijian Zhijian - 1 month ago 6
Java Question

How to render a remote JSP file with Java?

I want my server to render a remote JSP file and replace its variables with server given. The content of the JSP file is like below.

<div>
${alertContent}
</div>


I use
<c:import var="alertContent" url="http://www.google.com/example.jsp"/>
to import this remote JSP file, but I found the content is treated as
String
.

So my questions are:


  1. How to treat this file as a JSP file instead of String and replace the template with valid values?

  2. If the JSP file contains customer taglib, how to render it successfully?


Answer

JSP files are compiled on the server so the you cannot use the URL as JSP file. You will only get the rendered HTML output.

So the output you are getting is working as it supposed to work.