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>

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

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.

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

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)!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.