This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting more dynamic in a result page

 
jay akhawri
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi group,

i have some sort of problem in JSP which sure has an answer..but ,i am not figuring it out.

the problem no. 1
--------------------
i wrote a servlet which dispatches the search results( a pattern-matched set of employees) to my jsp as an advanced search ("/search_advance.do"). this set contains fields like name, age etc. and a primary key "EID".

at the same time i made a search criteria ("/search_basic.do") which only takes the "EID" to give full detail of the employee.

when a user gets result from the advanced search in a table,i want him to just click on the EID field to know full dtail of that employee. In short when he clicks an EID (in advanced result) he must be able to envoke "/search_basic.do?EID=theeid&B1=submit&formOption=basic"....so i wrote something like this

out.print("<td>");
out.print( " <A href=http://localhost:8888/sobis/search_basic.do?EID=" + element1 + "&B1=submit&formOption=basic>");
out.print(element1);
out.print("</A></td>");

formOption is a hidden field to distinguish basic form from advanced form(bcoz both are in the same page.)
It never worked..all i know is the same form("~/search_advanced.do?/search_basic.do?EID=theeid") is envoked again, with parameters shown in url.


// here is the scriptlet

<%
//Collected Lists

List mEID = (List)request.getAttribute("mEID");
List mfirst_name = (List)request.getAttribute("mfirst_name");
List mmiddle_name = (List)request.getAttribute("mmiddle_name");
List mlast_name = (List)request.getAttribute("mlast_name");
List maddress = (List)request.getAttribute("maddress");
List mjoining = (List)request.getAttribute("mjoining");


Iterator it1 = mEID.iterator();
Iterator it2 = mfirst_name.iterator();
Iterator it3 = mmiddle_name.iterator();
Iterator it4 = mlast_name.iterator();
Iterator it5 = maddress.iterator();
Iterator it6 = mjoining.iterator();
out.print(" <tr><th>EID</th><th>Last Name</th><th>First Name</th><th>Middle Name</th><th>Address</th><th>Joining</th></tr>");

// display it

while( it1.hasNext() && it2.hasNext() && it3.hasNext() && it4.hasNext() && it5.hasNext() && it6.hasNext())
{
Object element1 = it1.next();
Object element2 = it2.next();
Object element3 = it3.next();
Object element4 = it4.next();
Object element5 = it5.next();
Object element6 = it6.next();

out.print("<tr>");

out.print("<td>");
//out.print( " <A href=http://localhost:8888/sobis/search_basic.do?EID=" + element1 + "&B1=submit&formOption=basic>");
out.print(element1);
out.print("</A></td>");

out.print("<td>");
out.print(element4);
out.print(",</td>");

out.print("<td>");
out.print(element2);
out.print("</td>");

out.print("<td>");
out.print(element3);
out.print("</td>");

out.print("<td>");
out.print(element5);
out.print("</td>");

out.print("<td>");
out.print(element6);
out.print("</td>");

out.print("</tr>");
}
out.print(" </table>");
%>

/** @@@@@@@@@@@@@@@@@@@@ end @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/


problem no. 2
--------------------

how to do every thing which i am doing in JSP (getting result from db and showin') in a flash program.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jay,
Welcome to JavaRanch!

It's actually better to do this in a servlet and a JSP than just a JSP.

In the servlet, you do the query (as you are doing it now.) You place the results in a request attribute. Then in the JSP, you get the attributes from the result and display them.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic