Ask your own question, for FREE!
Computer Science 32 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
Twaylor: It's my birthday :D
7 hours ago 0 Replies 0 Medals
breiadabrattz: I thought C on this..
23 hours ago 39 Replies 2 Medals
breiadabrattz: I really don't understand this .
1 day ago 14 Replies 0 Medals
gelphielvr: How can I better memorize phrases in a different language?
18 hours ago 5 Replies 0 Medals
Breathless: Breathless Gang (join the cult)
1 day ago 1 Reply 0 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!