How to start a servlet automatically when index.jsp starts.
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>
iamcreasy
Junior Poster in Training
90 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
javaAddict
Nearly a Senior Poster
3,329 posts since Dec 2007
Reputation Points: 1,014
Solved Threads: 448
iamcreasy
Junior Poster in Training
90 posts since Nov 2009
Reputation Points: 10
Solved Threads: 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
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902
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.
iamcreasy
Junior Poster in Training
90 posts since Nov 2009
Reputation Points: 10
Solved Threads: 0
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
peter_budo
Code tags enforcer
15,436 posts since Dec 2004
Reputation Points: 2,806
Solved Threads: 902