Set String to clickable URL

谁都会走 提交于 2019-12-31 05:44:26

问题


Am I able to change one the attribute from normal text become an URL(hyperlink) so user will be able to click on it and redirect to another page.

Basically the attribute that I get from servlet is www.stackoverflow.com but is in plain text so my question is how do I change it to a clickable link?

Any expert out there know how to set it? Thank you so much and have a nice day!

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="2nd.css">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>THE SUPER SEARCH</title>
    </head>
    <body>
        <h4>Here's the following results</h4>
        <%
            String testresults=(String)request.getAttribute("testresults");
            out.print("" + testresults);
        %>
        <br>
        <br>
        <% 
            String testcontent=(String)request.getAttribute("testcontent");
            out.print("" + testcontent);
        %>
    </body>
</html>

回答1:


Put it inside an <a> tag.
Something like

<a href="<%=testresults%>"><%=testresults%></a>

Regards



来源:https://stackoverflow.com/questions/40060034/set-string-to-clickable-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!