View Full Version : How to jump to a profile by clicking on a hyperlink?
silversurface
04-09-2010, 05:15 AM
Basically creating a website for our comp dept in college..
Now consider a scenario : when a teacher or student logs in and is viewing someone else's blog ..when he clicks on the creator of the blog "which s a hyperlink" he should jump to the profile page of that user..How to do this?
Problem: Should i use session variables for this? I have created two session variables which are created at the time of login for the current user called email[this is unique] and usertype [teacher/student]
Suggested solution: Somehow i need to find a way to retrieve the text[email] printed within the anchor tag and make a search through the database to find a match with email of any user registered so that their profile can be displayed.
Anyone has any idea? :confused:
servlet
04-09-2010, 07:09 AM
This is a very simple problem
- Create a servlet that would take creater's userid/username as request parameter, fetch the data from database and display it.
- configure servlet and servlet mapping in web.xml
- point the link to that servlet and you are done.
- The link should have creator's user id appended as query string like this
<a href="viewProfileServlet?creatorid=123">View profile</a>
I would recommend that you have a look at this servlet example http://www.jsptube.com/servlet-tutorials/simple-servlet-example.html which explains all the basics of creating and configuring a servlet.
silversurface
04-10-2010, 06:31 AM
This is a very simple problem
- Create a servlet that would take creater's userid/username as request parameter, fetch the data from database and display it.
- configure servlet and servlet mapping in web.xml
- point the link to that servlet and you are done.
- The link should have creator's user id appended as query string like this
<a href="viewProfileServlet?creatorid=123">View profile</a>
I would recommend that you have a look at this servlet example http://www.jsptube.com/servlet-tutorials/simple-servlet-example.html which explains all the basics of creating and configuring a servlet.
Description: Basically the first page has display of links to all professors. These are present in a form as input type named emailz in a loop for display. Its in a loop so to fetch the diff links we can use
String emailz[ ]= request.getParamaterValues(emailz).
Which is working. Now in the next page while displayin each link i associate the email[z] element where z is an index to the anchor link like this :
<td> <a href="fomname.jsp?button=Info&email= <%= emailz[z] %>"><%= resultset.getString(3) %> </a> </td>
When i submit in the url of the next page i get --- "formname.jsp?button=Info&email= girish@site.com " where i had clicked on girish's link
Problem: But the query in this page is designed to display the profile of whose session variable email exists. Which is of the logged in user. Even if i change this i 'd like to find a way of using a session variable as an array that can hold the values of email[z] for diff values of z and then compare this session variable with email field of database and get the requested profile. Meaning at present i can only set the session variable to one link not to all. So is this possible? using session variable as an array?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.