<jsp:forward> problems

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 32
Reputation: eddy556 is an unknown quantity at this point 
Solved Threads: 0
eddy556 eddy556 is offline Offline
Light Poster

<jsp:forward> problems

 
0
  #1
Feb 26th, 2008
Hi,

I have a JSP which searches through a database of categories and displays each one with a unique link if clicked. When the link is clicked it sends it to itself and saves it into a variable. <jsp:forward> is then called which should send the variable as a parameter to the next page.

This is working correctly and I can retreive the parameter on the net page.

The funny thing is the next page only returns to the calling page information if I have little code in it, otherwise it is completely blank! Hopefully you can see from the code that the first two lines work correctly ONLY if I ommit the rest (below the comments)

  1. <%@ page import="java.sql.*" %>
  2. <%@ page import="java.util.*" %>
  3. <%@ include file="connection.jsp" %>
  4.  
  5.  
  6. <%String value = request.getParameter("category"); %>
  7. <%=value%>
  8.  
  9. //The code below here prevents the WHOLE page showing returning nothing to the page that called the <jsp:forward>
  10. //whereas without the above two lines work correctly
  11.  
  12. <%
  13.  
  14.  
  15.  
  16. ResultSet columns1 = statement.executeQuery("SELECT * FROM Questions");
  17.  
  18. while(columns1.next())
  19. {
  20. id = columns1.getString("ID");
  21. Question = columns1.getString("Question");
  22. Answer = columns1.getString("Answer");
  23. Updated = columns1.getString("Stamp");
  24. Author = columns1.getString("UserID");
  25.  
  26.  
  27. %>
  28. <a href="custarea.jsp?question=<%=Question %>"><%=Question %></a> <br />
  29.  
  30. <%
  31. if (Question.equals(key))
  32. {
  33. %>
  34.  
  35. <table border="1">
  36. <tr>
  37. <td>
  38. <%= Answer %>
  39. <% session.setAttribute("key", key); %>
  40. </td>
  41. </tr>
  42.  
  43. <tr>
  44. <td align="right">
  45.  
  46. <form name="useful" action="addrating.jsp" method="get">
  47. Was this answer useful?
  48. <select name="useful" onChange="send()">
  49.  
  50. <option>-</option>
  51. <option value="Yes">Yes</option>
  52. <option value="No">No</option>
  53. </select>
  54. </form>
  55.  
  56. </td>
  57. </tr>
  58. </table>
  59.  
  60.  
  61. <%
  62. }
  63.  
  64. } %>

This seems like such a novel problem, and I realise it probably has a simply solution.

Thanks for you help
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC