Ask your own question, for FREE!
Computer Science 13 Online
OpenStudy (anonymous):

Hello Friends, Plz help me to figure out what my problem is?(jsp code) thanks =)

OpenStudy (anonymous):

in my JSP page, I created a cell whose image source I want to get from servlet. I put the link tag to ask servlet for imgSrc, but it does not work . Please show me how to change the imgSrc in JSP page using servlet. I want the JSP to merely show the result, not a dispatch to another page. here is my code : Zbody> <form action="testServlet.java"> <TABLE border="0" align="center"> <TR height="40"> <TD width="40"><a href="Hoda/testServlet?direction=b"><img src=<%=request.getAttribute("imgSrc")%> width="40" height="40" /></a></TD> </form> </body> SERVLET: @WebServlet("/testServlet") public class testServlet extends HttpServlet { String imgSrc = "red.png"; protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IO hoda_mahmoodi: HttpServletResponse response) throws ServletException, IOException { String str = request.getParameter("direction"); if (str.startsWith("b")) { imgSrc = "black.png"; } request.setAttribute("imgSrc", imgSrc); } }

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Arriyanalol: cant wait for the new bluey movie in 2027
2 hours ago 5 Replies 1 Medal
MrsTooTac: naa shorty blew me askin me if i eat ahh wdf
8 hours ago 0 Replies 0 Medals
Arriyanalol: NOAH STINKS
9 hours ago 10 Replies 1 Medal
Arriyanalol: this app is broken
11 hours ago 1 Reply 0 Medals
blaster: i need friends new here
4 days ago 1 Reply 0 Medals
Arriyanalol: this is my cap idea imma decor it
6 days ago 10 Replies 3 Medals
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!