Hello I have a jsp with content like
<div id="somediv">Sample text</div>
<img id = "mainPicture" src = "file.jpg" height="1024" width="600"/>
and so on. Also I have a servlet, that has to handle requests and proceed response, that change jsp content (for example src in mainPicture and text in somediv).
How can I do that? Can I return some hashmap from servlet and handle it in javascript?
Well, I used jQuery and called there my servlet. Then I edited elements attributes with output data in that jQuery function.
just insert java code in jsp?
like
"<% java-code %>"
for direct output use "<%= java-code %>"
in your example:
<% String sample = "Sample teyt";
String fileSrc = "file.jpg"; %>
<div id="somediv"><%= sample %></div>
<img id = "mainPicture" src = "<%= fileSrc %>" height="1024" width="600"/>
now you just need to edit the Strings in Java when you want to edit the content there
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.