User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 427,199 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,278 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 824 | Replies: 0
Reply
Join Date: Jan 2008
Posts: 27
Reputation: eddy556 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
eddy556 eddy556 is offline Offline
Light Poster

Help <jsp:forward> problems

  #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
AddThis Social Bookmark Button
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 10:38 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC