0

How to start a servlet automatically when index.jsp starts.

To put it simple, here is the index.jsp file.

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<html>

    <head>
        <title>JSP Test</title>
    </head>

    <body>
        I want to put something here, so a servlet automatically starts without doing anything.
    </body>

</html>

Edited by iamcreasy: n/a

4
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by nore
0

What exactly you trying to do? Please explain as it seem like you want to call from same JSP on servlet to do something for you without moving from page which is not good concept. There can be something else better suited to the situation

0

What exactly you trying to do? Please explain as it seem like you want to call from same JSP on servlet to do something for you without moving from page which is not good concept. There can be something else better suited to the situation

Yes I want the index.jsp page to do nothing except redirecting to a servlet.

I am a noob learner, so this is something that I was just trying to do. Didn't really looked into creating something good.

1

You know the idea is that JSP page present some data. On button or link click you request something from server that is handled by servlet. Servlet handle this and then forward data JSP page.
So if you tell us little more about what you trying to do we can help. To get basic idea of JSP-servlet interaction you can always look at MVC tutorial at top of this section and there is also FAQ section that list various learning resources if you interesd

0

it's depend on server which you use. It should be JSP on the server, or you have one at the localhost (using some developer tools)!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.