开发者

Dealing with the pages of a website in my application

I have 2 pages written in JSP the first page contains:

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h1>Hello World!</h1>
        <a href="http://www.site.com/page1"> Page1 </a>
        <a href="http://www.site.com/page2"> Page2 </a>
        <a href="http://www.site.com/page3"> Page3 </a>
    </body>
</html>

the second page should take the content of the website spe开发者_运维问答cified in the href attribute and process these content then display the page with my modification ( my modification will be highlight specific words)

First, I do not know how to pass href value from one page to the second page? because I will not use form..

Second, after I pass the value of href (which is website page)How can I get the content of that page ?

Finally, How can I display the page of the website with my modification?

I used JQuery before to highlight specific words in the same document that contains the Jquery script. But when it comes to having just the link and dealing with document that is far from my application I do not know How?

Please help and thanks in advance


First, I do not know how to pass href value from one page to the second page? because I will not use form..

That will not achieve what you are trying to achieve.

Assuming that you are doing this without a plugin, what you actually need do is write a relay servlet that will read pages from this other site, insert stuff into them and return the resulting HTML to the user's browser.

Then you modify your existing JSP so that the hrefs look something like this:

  href="http://myrelay.com?url=http://www.site.com/page1"

with proper %-escaping added.

You then need to decide how much massaging of the HTML should be done by the relay servlet itself, and how much should be done by javascript that the relay inserts into the page.


Warnings:

  1. This is a complicated area. There are all sorts of potential issues with session cookies, internal links, javascript security sand-boxing, browser compatibility issues and so on.

  2. Don't try to do the work in a JSP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜