my dog learned polymorphism*
The moose likes JSP and the fly likes getting more dynamic in a result page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "getting more dynamic in a result page" Watch "getting more dynamic in a result page" New topic
Author

getting more dynamic in a result page

jay akhawri
Ranch Hand

Joined: Nov 28, 2004
Posts: 47
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

This conversation has drifted to:
http://www.coderanch.com/t/287152/JSP/java/jsp-thing


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting more dynamic in a result page
 
Similar Threads
XML Tranformation using XSLT
Iterating for non-collection object
HTML validation error: A form for each table row
Back ground color in Table rows, while using iterator
List in Descending order