开发者

How/Can you include/pull a table or data from a .jsp/.txt file into an HTML file for display on a web page?

开发者 https://www.devze.com 2023-04-12 18:20 出处:网络
I\'ve very new to web development stuff, so the more details you can include the better! [HTML is down, but JavaScript and more are still being practiced]

I've very new to web development stuff, so the more details you can include the better! [HTML is down, but JavaScript and more are still being practiced]

I'm making a web page and I want it to display one of two tables of data depending on whether option 1 or option 2 is checked. I've gotten a radio button hide/unhide system done to just show either one table or the other but now I'm stuck on how to populate my tables with data from some files.

  • The data I want to put in Table 1 is saved in a .jsp file.
  • The data I want to put in Table 2 is also in a .jsp file as well as in a plain text file (2 options).
  • The files are in the same dir as the .html file

Some notes:

  • The files for Table 2 are开发者_如何学JAVA created from a Perl Script that uses the file for Table 1 (.jsp)
  • For those unaware, the .jsp files are basically .html files w/ a different file extension it appears (I only know a little about .jsp files from Googling.)
  • Using Microsoft IIS; Server Side Technologies: ASP.NET 2.0/3.5/4.0

I know I could just open up those files and put the data into the .html file myself, however besides creating a wall of text in my html file, the data will be changing in the future and I don't want to have to keep editing the HTML file to update it.

So can anyone help me out? Code examples, tips, points in the right direction, or such is appreciated!

Languages I'm good with: C++, Perl, and just a bit of Java (what I can remember from a class).

Thanks StackOverFlow users!

My Current HTML Code: http://cl1p.net/c4sofmcc/

Feel Free to Edit This Code: http://cl1p.net/c4sofmcced/


You can use <jsp:include> to "import" a file ("include" is a better word).

E.g. form.jsp:

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
...

<form method="post">
  <label><input type="radio" name="table" value="1" onclick="submit()" ${param.table == '1' ? 'checked' : ''}>Show table 1</label>
  <label><input type="radio" name="table" value="2" onclick="submit()" ${param.table == '2' ? 'checked' : ''}>Show table 2</label>
</form>

<c:if test="${param.table == '1'}">
  <jsp:include page="table1.jsp" />
</c:if>
<c:if test="${param.table == '2'}">
  <jsp:include page="table2.jsp" />
</c:if>

Note that you need to ensure that you end up with syntactically valid HTML. So those files should not contain <html><head><body> and such. Otherwise you need to use an <iframe>. Ask help to http://validator.w3.org if necessary.

0

精彩评论

暂无评论...
验证码 换一张
取 消