Hyperlink

Hi All

I have a small servlet that displays some data from database, at the end of the page, i have a hyperlink, I want this hyperlink to go to a jsp page, how could i do this please?

for example:

This is inside the servlet, and i want it to move to page myJsp.jsp,

<a href="http://localhost:8080/jsp/myJsp.jsp">click here</a>

Thank you

[411 byte] By [jotnartaa] at [2007-11-27 9:39:07]
# 1

hi

in servlet last line

// put dot slash yourjspnmae./myjsp.jsp

ex:

***

out.println ( " <a href='./myJsp.jsp'>click here</a> ");

it will display in last line and if user click it will go to

http://localhost:8080/jsp/myJsp.jsp

drvijayy2k2a at 2007-7-12 23:13:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Sorry, it didn't work, I have the following structure:

in my web application, i have a folder called jsp, inside this folder i put my jsp files.

When i hover over the preceesded link i got the following in the taskbar:

http://localhost:8080/Exam/servlet/jsp/answers.jsp

it seems that we still in servlet context.

The right link is: http://localhost:8080/Exam/jsp/answers.jsp

Thank you

jotnartaa at 2007-7-12 23:13:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
out.println ( " <a href='../Exam/jsp/answers.jsp'>click here</a> ");
drvijayy2k2a at 2007-7-12 23:13:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Thank you

To go from a servlet to a jsp page, you need to encode your address like this:

String url = response.encodeURL("http://localhost:8080/Exam/jsp/results.jsp");

Then use the encoded URL in a hyperlink tag,

Thank you anyways buddy, thank you very much for your time and response

Jotnarta

jotnartaa at 2007-7-12 23:13:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...