Easy way to display JSP source on web

  • Thread starter Andrew Thompson
  • Start date
A

Andrew Thompson

I need an easy way to display JSP source in a
web page.

If I use..
<jsp:include page="/test/index.jsp" ></jsp:include> or
<%@ include file="/test/index.jsp" %>
...the jsp I want to include is merged with the
original page and (usually) throws exceptions.

Is there any way to include a jsp in a web page
but have it treated as if it were text?
 
W

Wendy S

Andrew Thompson said:
I need an easy way to display JSP source in a
web page.

I don't suppose it's as simple as wrapping it in <pre> tags? Works with
other stuff...
 
A

Andrew Thompson

Wendy S said:
I don't suppose it's as simple as wrapping it in <pre> tags? Works with
other stuff...

Unfortunately not. Here are some URL's of
stuff I have been working on, the first two use
TEXTAREA,
http://localhost:8080/codes/display.jsp?fl=index.jsp
http://localhost:8080/codes/display.jsp?fl=index.jsp?zip=ps
the third uses PRE..
http://localhost:8080/codes/display2.jsp?fl=index.jsp

I could use some classes I already have that
grab a file or URL as a string, but I still think
there must be an easier way..
 
C

Chris Smith

Andrew said:

Okay, so try <pre> *and* run the file contents (as a String) by this
first:

str = str.replaceAll("\\<", "&lt;");
str = str.replaceAll("\\>", "&gt;");
str = str.replaceAll("\\\"", "&quot;");

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

Sudsy

Wendy said:
I don't suppose it's as simple as wrapping it in <pre> tags? Works with
other stuff...

Even if you designate content as preformatted, tags still get
interpreted. I use bold tags and the like in preformatted text
all the time. The key is to escape the interpretation of the
tag start marker, namely the left angle bracket. Best to run
it through some form of processor which converts it to the
proper sequence first.
 
A

Andrew Thompson

Andrew Thompson said:
I need an easy way to display JSP source in a
web page.

Thanks to Wendy, Chris and Sudsy for your advice.

You can see my implementation, here..
http://www.physci.org/codes/display.jsp?fl=codes/display.jsp

Now that I see it, the original question
does seem kind of silly. :)

It is probably not very robust, but it seems to
work well enough for my purposes, ..well enough
to come in here screaming "Why won't my JSP
work?!? Here's the code.." ;-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top