need help
  1. need help (4 messages)

    Hello Friends,

    We are developing a site using servlets which requires storing stats like os name,browswe name,page hit date etc in the database.Further we have to put hit counter in the main page of our site.We are currently using java webserver 2.0. For this purpose i wrote a servlet name(Example) which take all the needed information and store it in the database.I map this file with welcome.html using servlet aliases option in server adminstration. Upto this point i have to no problem. Now i have to map this html file(welcome.html) to our site(for example www.something.com).
    For this i open admin and in site option i add this file(welcome.html).But when i gave like this www.something.com it is not working.It is giving file not found error.The same thing we can do using servlets.But i want to do it using servlets only.

    what's my mistake?

    Is there any way to do the same thing using html and java script

    Is there any solution for this using servlets


    Thanks in advance,

    sreedhar garimella.

    Threaded Messages (4)

  2. need help[ Go to top ]

    Sreedhar,

       What servlet engine are you using? We could probably help you if you were more specific about how you deployed it.

        It sounds like you are trying to map your Example servlet to a file called "Welcome.html"... Why don't you try this:

        In your home page, do a JSP:include on your example servlet somewhere at the top of your page. Now whenever someone hits your homepage, the Example servlet will silently record the users stats without the complication of adding more files, etc. Just make sure that the Example servlet doesn't output anything, or else it will interfere with the page it is being included from.

    take care,

    Floyd
  3. need help[ Go to top ]

    Hi Floyd,

    First of all my sincere thanks to you.Currently we are deploying our site on Javawebserver 2.0.

    U r giving one solution for my problem.In my home page just use <jsp:include ..../> tag on Example servlet.If that is the case i have to save my home page as .jsp file.Is it right?(If any thing wrong please correct me).We develop entire site using servlets.I felt if home page only jsp file it is some what ambiguous.

    What i did:
    -----------

    what i did was create one servlet (name Example).Through that i store all the stats in data base using request headers. Further i through required html of my home page.
    In adminstration i open servlet aliases and map one alias name welcome.html to this servlet.So, when ever i give like this http://localhost:8080/welcome.html the underneth servlet invokes and stores stats in the database and display html content. Now i want to map this welcome.html to my site(say www.something.com).For this i open site option in adminstration i put this welcome.html. What my idea is when i gave like this www.something.com it opens welcome.html (in fact it invokes Example servlet stores info and throws html). At this point my idea failed and i got file not found error.I thought why this error occurs because my welcome.html is not physical exist in the public_html(if not please correct me).

    Inorder to overcome this problem I did another thing.I create one html file name home.html.In the body onLoad event
    i gave like this location.href=/welcome.html and i save this
    file in public_html.Now in site option of admin i map this home.html to my site(www.something.com).

    So when i gave like this www.something.com it opens home.html which in turn calls welcome.html which in turn invokes Example servlet and store all the required info and through the home page html content.

    Upto this point my idea works fine.When my project leader saw the site and click on back button it did not go back because in body onload i gave like this location.href=/welcome.Inorder to go back we have to click two times.Project leader did not like this.He wanted it has to go back for one click.Here i face this problem.

    Inorder to do the same thing which my pl wanted is there any solution?(if it is javascript ok for me)

    In the above process is there any mistake(please correct me).



    thanks in advance,
    waiting for u r reply,
    regards,
    sreedhar garimella.

  4. need help[ Go to top ]

    Sreedhar,

      Just make your Welcome.html a JSP file (welcome.jsp). At the top of this file to a JSP include on your example servlet, which will record all the users stats. Now instead of outputting html from the example servlet, just put this html in the Welcome.jsp!

      This solution is simple, easier to maintain (html in the jsp, not in the servlet), and more reuseable (you can call this example servlet from any page now, re-use it across projects, etc).

       You also won't have the "back" button problem you mention. The only other thing you have to do is make sure that your webserver will show an index.jsp (or Welcome.jsp) by default when a user goes to your URL.

      take care,

    Floyd
  5. tes<i>t</i>[ Go to top ]

    tes<i>t</i>