Click to See Complete Forum and Search --> : JSP - including files
<%
String bar = request.getParameter("bar");
out.println (bar);
out.println ("<BR>");
%>
<%@ include file=bar %>
-------------
For some reason this doesn't work. I want it so that I can point the browser at test.jsp?bar=foo and it will include the file "foo" -- I know this isn't secure, but once I figure this out I can go from there.
Any ideas ?
is what I have now.
nanode
08-31-2001, 02:23 PM
I've never included a file into a JSP, but I do have a suggestion.
whenever you're getting parameters, do something like this:
String bar = "";
if(request.getParameter("bar") != null) {
bar = request.getParameter("bar");
}
in your case bar is a String object. It is not a File object. (I'm not sure if that include directive cares, or how it works)
Also, this is mostly stylistic, but I like to seperate my JSP(PHP, python, etc) from my HTML.
It's more typing to do:
...JSP stuff
%>
<BR>
<%
...more JSP stuff
than
out.println ("<BR>");
If/when you need to print Java values into your HTML, just do like:
<TR><TD><%=variable%></TD></TR>
that's a lot more readable when your HTML gets complex than trying to look at out.println for dozens of lines.
jemfinch
09-05-2001, 02:47 PM
Originally posted by tminos:
mm.... bump
Sounds like a Hanson song :)
Jeremy
Dru Lee Parsec
09-06-2001, 01:57 PM
Timinos:
I'd love to help you out, but I am so swamped with trying to get my task done in the last 2 days of this job that I just don't have time.
I'll try to get to it tonight though. I just wanted to let you know that you're not being ignored.
BTW, It's good to see you writing code buddy. :)