Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 162
  • Last Modified:

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
0
gotchi
Asked:
gotchi
  • 8
  • 6
1 Solution
 
cheekycjCommented:
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
0
 
gotchiAuthor Commented:
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();
0
 
cheekycjCommented:
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
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
gotchiAuthor Commented:
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! :)
0
 
cheekycjCommented:
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
0
 
gotchiAuthor Commented:
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.
0
 
cheekycjCommented:
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
0
 
sathit_p16Commented:
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>

0
 
cheekycjCommented:
so does it work now?

CJ
0
 
gotchiAuthor Commented:
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
0
 
cheekycjCommented:
can you post your current code.

Thanx,
CJ
0
 
gotchiAuthor Commented:
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>
0
 
cheekycjCommented:
I still see a missing starting <td> so try this:
<%
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>
    <td><a href="mailto:<%=EmailAddress%>"><%=EmailAddress%></a></td>
</tr>
<% } %>
</table>

CJ
0
 
gotchiAuthor Commented:
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 ;)
0
 
cheekycjCommented:
glad I could help and thanx for the "A"

CJ
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 8
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now