Setup: iMac 10.6.8, Apache Tomcat 6.0.16, eXist DataBase, JSP, Java, XML
I have a JSP page that is used to take keyword requests from users and return XML content.
Depending on the content of the title XML tag returned to the user I am looking to also display additional content pulled from an external Java project.
My JSP to pull XML content
<div class='result-container'>
<%
(more code here to call content from XML database and transform)
content = AE.getPrettyModelContent("ae", username + "transformedFeatureModel");
out.println(content);
%>
</div>
This content is outputted with a verity of tags that are then used for styling e.g.
<title>France</title>
Gets outputted as
<div id="title">France</div>
I am looking to preform another action on my JSP page depending on the content of the above outputted tag.
My attempt so far
<div class='concept-container'>
<%
Injector injector = Guice.createInjector(new GuiceInjector());
ConceptConnector myConceptFrance = injector.getInstance(ConceptConnector.class);
if (div id="title" == France)
{
out.println(myConceptFrance.search(myConceptFrance));
}
%>
</div>
The Error
An error occurred at line: 150 in the jsp file: /SimpleResponse2.jsp
div cannot be resolved
149:
150: if (div id="title" == France)
151: {
152: out.println(myConceptFrance.search(myConceptFrance));
153: }
I am not a 100% sure that what im trying to do is possible and there does not appear to be a lot of information on it. If anyone can give any tips it would be very much appreciated.
I may not fully understand, the question, but based on:
if (div id="title" == France)it sounds like you’re trying to parse and edit the HTML that you output some HTML that you output here:out.println(content);. This is impossible (you can’t read the output HTML back into the Java)Here are some possible workarounds to consider:
Instead of directly using out.println() when you want something to be added to the page, use a
StringBufferor something to keep a copy of what you’re printing so you can search it later. — Maybe (if you don’t need to manipulate something after printing it you doout.printlnAND write it to theStringBuffer, then you can search, see below:I’m sure there’s other solutions as well, but that’s what I’ve can think of right away. Hope this helps.