Link to home
Start Free TrialLog in
Avatar of gotchi
gotchi

asked on

Email Address hyperlinks?

Hello

Im wondering if anyone can help me with this... Im using ms access as my database with jsp. I have a column that holds email addresses, when I search for a particular person, and they are retreived, how will i be able to click on the email address, when the record comes up and open it up in my OutLook Express. so that the user can type in a message if they want to. Does the hyperlink have to set in Access or is the a way of coding it in jsp.

Please help
Avatar of cheekycj
cheekycj
Flag of United States of America image

you can use the html tag mailto

Now if the user has Outlook configured as their default email program it will be launched otherwise their default email prog will be launched.

<%
Connection conn = null;
// .. setup conn here
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select email_address_column from your_table");
while(rs.next()) { %>
  <a href="mailto:<%=rs.getString("email_address_column")%>">=rs.getString("email_address_column")%></a>
<% } %>
<%
rs.close();
stmt.close();
conn.close();
%>

CJ
Avatar of gotchi
gotchi

ASKER

That sort of worked, it did open in outlook express but i have a table, so when the values are returned i.e name, surname and the email address i shud be able to click on the email address. At the moment when it runs....

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
   <td><b>First Name</b></td>
   <td><b>Surname</b></td>
   <td><b>Address</b></td>
   <td><b>Phone number</b></td>
   <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
     {
%>
     <tr>
     <td><%=RS.getString("FirstName") %></td>
     <td><%=RS.getString("Surname") %></td>
     <td><%=RS.getString("Address") %></td>
     <td><%=RS.getString("Number") %></td>
     <a href="mailto:<%=RS.getString("EmailAddress")%>">=RS.getString("EmailAddress")</a>
</tr>

   

<% } %>
<%
   RS.close();

connection.close();
try this:

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
  <td><b>First Name</b></td>
  <td><b>Surname</b></td>
  <td><b>Address</b></td>
  <td><b>Phone number</b></td>
  <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
    {
    String emailAddress = RS.getString("EmailAddress");
%>
    <tr>
    <td><%=RS.getString("FirstName") %></td>
    <td><%=RS.getString("Surname") %></td>
    <td><%=RS.getString("Address") %></td>
    <td><%=RS.getString("Number") %></td>
    <a href="mailto:<%=emailAddress%>"><%=emailAddress%></a>
</tr>

 

<% } %>
<%
  RS.close();

connection.close();

CJ
Avatar of gotchi

ASKER

hi,
we are getting a lot closer now:) The email address is showing now,but it is still sitting on top of the table. I have tried to move the code about, but it wont budge! :)
I don't understand that it is on top of the page and it won't budge?

Are you sure your changes in the JSP are showing up?

delete your work directory and then try accessing the page.

CJ
Avatar of gotchi

ASKER

what I mean is whilst all the returned values i.e. name, surname etc, are in each of their individual columns, the email address column is blank, beacuse the email address returned is at the top of the table and not in the actual column.
missing the wrapping <td> I think :-)

=RS.getString("EmailAddress" shows at the top of my table, and my email column is blank... my code is below

<table BORDER WIDTH="100%" >
<tr>
 <td><b>First Name</b></td>
 <td><b>Surname</b></td>
 <td><b>Address</b></td>
 <td><b>Phone number</b></td>
 <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
   {
   String emailAddress = RS.getString("EmailAddress");
%>
   <tr>
   <td><%=RS.getString("FirstName") %></td>
   <td><%=RS.getString("Surname") %></td>
   <td><%=RS.getString("Address") %></td>
   <td><%=RS.getString("Number") %></td>
   <td><a href="mailto:<%=emailAddress%>"><%=emailAddress%></a></td>
</tr>

 

<% } %>
<%
 RS.close();

connection.close();

CJ
I think previous comment is true but forgot to close tag table

 
<table BORDER WIDTH="100%" >
<tr>
<td><b>First Name</b></td>
<td><b>Surname</b></td>
<td><b>Address</b></td>
<td><b>Phone number</b></td>
<td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
  {
  String emailAddress = RS.getString("EmailAddress");
%>
  <tr>
  <td><%=RS.getString("FirstName") %></td>
  <td><%=RS.getString("Surname") %></td>
  <td><%=RS.getString("Address") %></td>
  <td><%=RS.getString("Number") %></td>
  <td><a href="mailto:<%=emailAddress%>"><%=emailAddress%></a></td>
</tr>



<% } %>
<%
RS.close();
connection.close();
%>
</table>

so does it work now?

CJ
Avatar of gotchi

ASKER

nope that didnt make a difference, whether the tag was there or not :( the email address is still not in the email column.
What now?

gotchi
can you post your current code.

Thanx,
CJ
Avatar of gotchi

ASKER

This is my code as it currently stands

String sql = ""
   + " SELECT   FirstName, LastName, Address, PhoneNumber, EmailAddress "
   + " FROM Employee"
   + " WHERE FirstName = '" + request.getParameter("FirstName") + "'"
   + " AND LastName = '" + request.getParameter("LastName") + "'";
   
java.sql.PreparedStatement statement = connection.prepareStatement(sql);
ResultSet RS = statement.executeQuery();
%>

<table BORDER WIDTH="100%" >
<tr>
   <td><b>First Name</b></td>
   <td><b>Surname</b></td>
   <td><b>Address</b></td>
   <td><b>Number</b></td>
   <td><b>Email Address</b></td>
</tr>
<%
while(RS.next())
     {
String EmailAddress = RS.getString("EmailAddress");
%>
     <tr>

     <td><%=RS.getString("FirstName") %></td>
     <td><%=RS.getString("LastName") %></td>
     <td><%=RS.getString("Address") %></td>
     <td><%=RS.getString("PhoneNumber") %></td>
     <a href="mailto:<%=EmailAddress%>"><%=EmailAddress%></a></td>
</tr>
ASKER CERTIFIED SOLUTION
Avatar of cheekycj
cheekycj
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gotchi

ASKER

Thanks

I was looking at the wrong tag the whole time, thinking to myself what is "cheekyci" going on about!!! But it was my mistake, so thanxxxx

I'll post some more problems later ;)
glad I could help and thanx for the "A"

CJ