943,867 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Marked Solved
  • Views: 26846
  • JSP RSS
Jul 27th, 2006
0

How to use a Hyperlink to send info to a servlet

Expand Post »
Hi, all

What I am trying to do is to put a hyperlink on my jsp page. Then, when I click on the link, I will come to the linked page and as well the page can get some info from the jsp page.

How is the code like?

thanks.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KilluaX is offline Offline
6 posts
since Jul 2006
Jul 27th, 2006
0

Re: How to use a Hyperlink to send info to a servlet

what you have to do is design a bean which will hold what ever information you want to and pass to any other page on your site
this can be done before a link was clicked or when you click link you run process which set-up bean for you, then on other side you just call bean and pull your info from it

there is plenty of tutorials on google
Last edited by peter_budo; Jul 27th, 2006 at 1:17 pm.
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Jul 27th, 2006
0

Re: How to use a Hyperlink to send info to a servlet

Hi, peter

thanks for your reply

I see some tutorial on net about javabean, but I found it's a bit complicated for me now.

Can I just simply use a hyperlink like this <a href="linktosomepage" onclick="whatever"></a> to do it?

I search the net and it seems got kind of way to do it, but I can't find the exactly code. Does anyone know this?
Last edited by KilluaX; Jul 27th, 2006 at 2:27 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KilluaX is offline Offline
6 posts
since Jul 2006
Jul 27th, 2006
0

Re: How to use a Hyperlink to send info to a servlet

Can you please tell me what exactly you are trying to do so I can help you more efficiently?

Just collect some info from user and display it on other page or you want to store it somewhere and use on different palces on your site?
Moderator
Featured Poster
Reputation Points: 2786
Solved Threads: 873
Code tags enforcer
peter_budo is offline Offline
6,656 posts
since Dec 2004
Jul 27th, 2006
0

Re: How to use a Hyperlink to send info to a servlet

ok

generelly, what i'm trying to do is to set up a simple mail server using java servlet as well as jsp

Now, my program can already show the subjects of all the mails in the inbox(this page call inbox.jsp)

I want to do that, when I click on the subject of any mail, will come to a new page that shows the content of the mail(come to content.jsp and show the content of certain mail).

My servlet already collect all information and pass them to the inbox.jsp

The problem is that content.jsp don't which mail to display when i click the link.So i want the hyperlink to send something to tell content.jsp which page i want and what is the content of it.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KilluaX is offline Offline
6 posts
since Jul 2006
Jul 28th, 2006
0

Re: How to use a Hyperlink to send info to a servlet

Thanks for your help, guy

I think I already find the solution.

first, create a form with a hidden input like this

JSP Syntax (Toggle Plain Text)
  1. <form name=form method=post action=anypage><input type=hidden value=xxx name=getit></form>

then, add a hyperlink with a submit function

JSP Syntax (Toggle Plain Text)
  1. <a href='javascript:document.form[0].submit()'>send it!</a>

ok, that's it

I hope it will be helpful if anyone got the same problem with me

and thank you again, peter
Reputation Points: 10
Solved Threads: 0
Newbie Poster
KilluaX is offline Offline
6 posts
since Jul 2006
Aug 1st, 2006
0

Re: How to use a Hyperlink to send info to a servlet

you could also create a regular link and pass the paramters as follows:

Last edited by DeAdPaCe; Aug 1st, 2006 at 2:49 pm.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
DeAdPaCe is offline Offline
2 posts
since Oct 2003
Dec 1st, 2008
0

Re: How to use a Hyperlink to send info to a servlet

Click to Expand / Collapse  Quote originally posted by DeAdPaCe ...
you could also create a regular link and pass the paramters as follows:

I find this solution better. I tried the one with javascript, but it worked only partially. I created a few forms, each containted a hidden input
JSP Syntax (Toggle Plain Text)
  1. <input type="hidden" name="param" value="a number" />
and
JSP Syntax (Toggle Plain Text)
  1. <a href='javascript:document.form[0].submit()'>send it!</a>
The value from this input was different for each form on this page, the forms had the same name(dynamically generated).
It turns out I did something wrong(I don't know what, because I don't know JavaScript yet), each time a clicked the link, the right servlet went into action, but with the wrong parameter.
Each time it was only the parameter from the first hidden input. The rest was ignored.
When using the second option,
JSP Syntax (Toggle Plain Text)
  1. <a href="www.yoursite.com/yourservlet?param=value">link</a>
my app works right.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
missalexa is offline Offline
1 posts
since Dec 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: security authentification using JDBCRealm under tomcat 6 and postgresql
Next Thread in JSP Forum Timeline: jsp with ajax





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC