hyaku
asked on
Linking to other website
inside my database, i have a column for the website url.. i was able to retreive it and use it as a hyperlink.. but there is a problem..
it says : The requested resource (/myFolder/www.yahoo.com) is not available.
thats is not what i wanted..it shouldn't go to myFolder to find the webiste..what i want is direct linking to the yahoo webpage..
pls help..thank you..
*the codes are done inside a servlet..
it says : The requested resource (/myFolder/www.yahoo.com) is not available.
thats is not what i wanted..it shouldn't go to myFolder to find the webiste..what i want is direct linking to the yahoo webpage..
pls help..thank you..
*the codes are done inside a servlet..
can you post the code that is giving the error
ASKER
ok.
-------------------------- ---------- --
package com.search;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
//import com.register.*;
public class SearchServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("t ext/html") ;
PrintWriter out = response.getWriter();
StringBuffer result = new StringBuffer(2048);
SearchBean searchBean = new SearchBean();
String s = request.getParameter("sear chCategory ");
String d = request.getParameter("sear chDescript ion");
Vector shopName = new Vector();
shopName = searchBean.searchResultsNa me(s, d);
Vector shopWebsite = new Vector();
shopWebsite= searchBean.searchResultsWe bsite(s, d);
if(shopName.size()!=0)
{
out.println("<html>");
out.println("<head>");
out.println("<title>Search Results</title>");
out.println("</head>");
out.println("<body>");
out.println("<center>");
out.println("<font size = 5>");
out.println("<strong>Searc h Results</strong>");
out.println("</font>");
out.println("<HR></HR>");
for(int i = 0; i<shopName.size();i++)
{
String shop = (String)shopName.get(i);
out.println("<p align = left>");
out.println("<B><U>");
out.println(shop);
out.println("</B></U>");
out.println("<BR>");
String website = (String)shopWebsite.get(i) ;
if(shopWebsite.get(i) == null)
{
out.print("Website: ");
out.println("N/A");
out.println("<BR>");
}
else
{
out.print("Website: ");
out.println("<a target=_blank href = "+website+">"+website+""); <--this part
out.println("<BR>");
}
out.println("</a>");
out.println("</p>");
}
out.println("<DIV ID = back>");
out.println("<A HREF = /myFolder/home.jsp>");
out.println("<FONT SIZE = 2>");
out.println("<STRONG>[Back to home page]</STRONG>");
out.println("</FONT>");
out.println("</A>");
out.println("</DIV>");
out.println("<br>");
out.println("</center>");
out.println("</body>");
out.println("</html>");
}
}
}
--------------------------
package com.search;
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
//import com.register.*;
public class SearchServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse response)throws IOException, ServletException
{
response.setContentType("t
PrintWriter out = response.getWriter();
StringBuffer result = new StringBuffer(2048);
SearchBean searchBean = new SearchBean();
String s = request.getParameter("sear
String d = request.getParameter("sear
Vector shopName = new Vector();
shopName = searchBean.searchResultsNa
Vector shopWebsite = new Vector();
shopWebsite= searchBean.searchResultsWe
if(shopName.size()!=0)
{
out.println("<html>");
out.println("<head>");
out.println("<title>Search
out.println("</head>");
out.println("<body>");
out.println("<center>");
out.println("<font size = 5>");
out.println("<strong>Searc
out.println("</font>");
out.println("<HR></HR>");
for(int i = 0; i<shopName.size();i++)
{
String shop = (String)shopName.get(i);
out.println("<p align = left>");
out.println("<B><U>");
out.println(shop);
out.println("</B></U>");
out.println("<BR>");
String website = (String)shopWebsite.get(i)
if(shopWebsite.get(i) == null)
{
out.print("Website: ");
out.println("N/A");
out.println("<BR>");
}
else
{
out.print("Website: ");
out.println("<a target=_blank href = "+website+">"+website+"");
out.println("<BR>");
}
out.println("</a>");
out.println("</p>");
}
out.println("<DIV ID = back>");
out.println("<A HREF = /myFolder/home.jsp>");
out.println("<FONT SIZE = 2>");
out.println("<STRONG>[Back
out.println("</FONT>");
out.println("</A>");
out.println("</DIV>");
out.println("<br>");
out.println("</center>");
out.println("</body>");
out.println("</html>");
}
}
}
looks like the value of website is incorrect, it should be an absolute url such as:
http://www.yahoo.com/
http://www.yahoo.com/
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
why i didn't think of that..it works
thank you objects.
thank you objects.