I created a webpage contains more than 10 links . is it possible to store the clicked urls or visited in my database or file . I have developed webpage using servlet. It is just a page with 10 links.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Capturing simple hits on your own site/servlet is easy as pie – if you just want to know the URLs visited, you can almost always set your webserver to record this to a logfile. (Then if desired you can parse and insert this into your database).
Capturing outbound links requires a little more works, and there are many ways to go about this, with the best depending on your specific requirements (complexity of URLs/methods, complexity of alternative link attributes such as
target, desired robustness, desired performance, desired comprehensiveness, etc.).One solution as specified above is changing all outbound links into references to a redirection page on your own site, with the target as a parameter. Then in your typical webserver logs you’ll see a hit something like
http://example.com/redir.html?target=http%3A%2F%2Fwww.bbc.co.uk%2Fnews, from which you can easily parse the target URL.Another would involve firing a manual request to your server when the link is clicked (typically a 1×1 image), to which you can append any query parameters you like and later extract them from your logfile. This may or may not involve interrupting the click action with a javascript event listener and then retriggering the page change later on, depending on exactly how you’re making the request as often this will lead to a race condition if not explicitly handled.
All of the options above that make explicit requests for the purpose of creating a line in the logfiles, could instead make a request to a particular page (e.g. a JSP) that writes entries directly into your database, if required (though ideally this would still keep some kind of log to allow for retrying failed inserts).
Having worked in web analytics for several years, I can tell you that it’s surprising just how many different situations there are to consider if you want to capture as much accurate information as possible. If this is just for a toy website for your own edification then just about any technique will likely be acceptable, but as soon as you start to put any weight behind the figures you really need to care about the things you never considered. There’s a reason why a market exists for several relatively expensive web analytics software packages… 🙂
Edit: As prakash’s comment implies, my recommendation would be to inspect the range of free web analytics tools already out there and integrate one if you actually care about the results. If you’re just doing this out of curiousity, or as a throwaway low-importance project then by all means get your hands dirty.