Solved

Search by keyword-Organization name displayed in links

Posted on 2003-11-08
13
262 Views
Last Modified: 2010-04-01
Hi,

  I  posted a question at
 http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_20789534.html
and i understood.Now my problem is that when the table gets' displayed it is too croweded.
It would be much better if after the search, if the organization name could be displayed as links, for example, when the user enter old folk home, lamb home, the name or the project name or anything, the name of the organization gets displayed in links and when the user click the link, a pop-up window that displays the table get displayed.

Can it be done,  i tried modiying the code but i made it worse.

I really need this urgently but unfortunately my pc crash so i am using a cybercafe, and there might be late in response.

Thanks
0
Comment
Question by:Jasbir21
  • 8
  • 3
  • 2
13 Comments
 
LVL 14

Expert Comment

by:kennethxu
ID: 9709817
if you display a link like this:
<a target='mypopup' href='yourdisplaytable.jsp?organizationid=<%=rs.getString("organizationid")%><%=rs.getString("organization")%></a>

and in the yourdisplaytable.jsp, you retrieve organizationid from parameter and render the table in popup window.
0
 
LVL 19

Accepted Solution

by:
Kuldeepchaturvedi earned 250 total points
ID: 9712260
<a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString("organizationid")%><%=rs.getString("organization")%></a>

In this case you will have to read the database again in your pop up window...
i.e. in popup.jsp you will write like...

<%@ page import="java.sql.* ,com.dhal.*"%>
<%@ page import="java.util.StringTokenizer, java.lang.*"%>
<jsp:useBean id="s" class="com.dhal.skil" scope="session"/>
<jsp:setProperty name="s" property="*"/>
<html>
<body BGColor="#FFFFF0">
<%
String org=request.getParameter(organizationid");
String connectionURL = "jdbc:mysql://localhost:3306/mydatabase?user=;password=";
  Connection connection = null;
  Statement stmt=null;
  ResultSet rs=null;
 
  try
  {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    connection = DriverManager.getConnection(connectionURL, "", "");
   
    String getOrg="select * from organ where organizationid='"+org+"'";
    stmt=connection.createStatement();
    rs=stmt.executeQuery(getOrg);
if(rs.next())
{
%>
<FORM>
//Here you can write your HTML in whatever way you want to write it up. All the data can be fecthed by doing <%=rs.getString(1)%> or whatever column number you are trying to retrieve.
</FORM>

<%}%>

>>>>>>>>>>>>> Another possible way is to pass all the data as parameters.. something like

<a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString("organizationid")%>&oggname=<%rs.getString("orgname")%>&skill=<%=rs.getString("skill")%>...........(and so on for all the values)<%=rs.getString("organization")%></a>

now inside the popup.jsp all you will have to do is
request.getParameter("skill");
request.getParameter("orgname");

and so on...
and then make the HTML out of it.

Hope this helps.
0
 

Author Comment

by:Jasbir21
ID: 9712425
hi, i am unable to try it out, because my pc crash, would be ok in a days time.
Sorry for the late response,
0
 

Author Comment

by:Jasbir21
ID: 9712826
.....
<a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString("organizationid")%><%=rs.getString("organization")%></a>
...
I think i understood but my problem is if in there are 5 projects that belong to little lamb,

i think the output would be
Little lamb(link)
Little lamb(link)

How to modify it , if the link is already there, there is no need to repeat the link.

...
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9713141
Hmm............ Thats where it gets interesting....... may be you can enclose your link creation code inside a if condition....
This if condition will look if the link with this name is already created or not, if yes then it will skip the creation other wise it will create the link..
Now the problem is that you can do this on a ResultSet.....:-)
so the easyway out is to put them in a vector/Hashtable/Set or any itereator of your choice...

a rough code sniplet will look something like this..

Set s = new Set();
while(rs.next()) //your loop of resultset
{
String val=rs.getString("organization");
if(!s.contains(val))
{
//create the link
s.add(val)
}//end if
}//end while
This way you will not create the duplicate link...

One possible way may be to put DISTINCT clause in your query that will also solve the problem..
Hope this helps
0
 

Author Comment

by:Jasbir21
ID: 9713287
..one more confusion, sorry, in the previous question, the user would be able to use skill, organization name, or keyword,

The only difference would be that the eventhough , the user could type in project,skill,or keyword, the organization name would be displayed.

Sorry, i am unable to try it out at the moment, coz of pc crash,so, i am still able to use the previous code, right, ..
from top to
select query where +=id,
so this id would need to be sent to pop-up,is this right,
thanks
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9713550
You lost me completely...:-) I am sorry I am not able to get what you are saying in above comment..
I think you should be sending the keys of your table to pop-up. and these ids will come down to your result sets anyways so you should be able to send them from there.
0
 
LVL 14

Assisted Solution

by:kennethxu
kennethxu earned 100 total points
ID: 9715434
>> <a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString("organizationid")%><%=rs.getString("organization")%></a>
isn't it the same thing that I had suggested ? :-)

>> my problem is if in there are 5 projects that belong to little lamb
you can use:

select distinct organizationid, organization from .... where ....

so you only get one line per organization.
0
 

Author Comment

by:Jasbir21
ID: 9721055
no,it's ok,it was my fault. i am sorry for the late response...I haven't got my pc still,would get it in a day's time.

thanks
0
 

Author Comment

by:Jasbir21
ID: 9721057
..pls give me a bit more time..
Thanks
0
 

Author Comment

by:Jasbir21
ID: 9744487
..I am very sorry for posting the points late.I would close this question first ,  i think i understand the idea..

..thanks
0
 

Author Comment

by:Jasbir21
ID: 9744939
hi,
  I splitted the points becoz but answers are correct.
Thanks
0
 

Author Comment

by:Jasbir21
ID: 9745104
..when i put this:

<a target='mypopup' href='popup.jsp?organizationid=<%=rs.getString( "organname") %>&skill=<%=rs.getString("skillid")%>>

</a>


there is no link being displayed but this:

<a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Teacher> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Doc> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Teacher> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Doc> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Doc> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Doc> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Teacher> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=fff , bb> <a target='mypopup' href='popup.jsp?organizationid=Mercy&skill=Teacher, Doc>

thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Note: This is the third blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   We’ve been talki…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now