Basic Servlet help

D

Dakota Mon

Ok heres my situation....

I am using NetBeans 4.1 and just doing a simpler than "Hello World" web
app.
I have a web module which has a servlet called "Control1". I have 4
JSPs. There is the "index.jsp" which comes by default and then there
are 3 which I Created. One if called "mainPage.jsp".

Here is what I want to have happen. When someone goes to my webpage,
the servlet "Control1" is called and instantly passes control over to
and displays "mainPage.jsp".

My questions are ...
1) What is the default page used when the URL is invoked?

2) If the default page is not the servlet then how do I set it to be
the servlet "Control1"?

3) How then do I pass on to a JSP to display? This also includes the
question of how do I make the JSP page available/visible to the
servlet?

4) Within "mainPage.jsp" I want to collect info. How do I then pass
this info back to the servlet "Control1"?



I will eventually deploy to the Sun Applicationn Server but right now I
am just working with this within the NetBeans environment.
 
T

trippy

Dakota Mon took the hamburger, threw it on the grill, and I said "Oh
wow"...
Ok heres my situation....

I am using NetBeans 4.1 and just doing a simpler than "Hello World" web
app.
I have a web module which has a servlet called "Control1". I have 4
JSPs. There is the "index.jsp" which comes by default and then there
are 3 which I Created. One if called "mainPage.jsp".

Here is what I want to have happen. When someone goes to my webpage,
the servlet "Control1" is called and instantly passes control over to
and displays "mainPage.jsp".

My questions are ...
1) What is the default page used when the URL is invoked?
mainPage.jsp


2) If the default page is not the servlet then how do I set it to be
the servlet "Control1"?

Just put the servlet up if you're gonna do that and lose the .jsp pages.
3) How then do I pass on to a JSP to display? This also includes the
question of how do I make the JSP page available/visible to the
servlet?

You do this with the action attribute of the form element.

<form action="/servlet/path.to.your.servlet" method="get" >
</form>

You can also use method="post". Anything more complicated than that and
you'll have to find someone who knows more than I do.

4) Within "mainPage.jsp" I want to collect info. How do I then pass
this info back to the servlet "Control1"?

request.getParameter("textFieldID");



--
trippy
mhm31x9 Smeeter#29 WSD#30
sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

NP: "Jelly Roll" -- Blue Murder

"Now, technology's getting better all the time and that's fine,
but most of the time all you need is a stick of gum, a pocketknife,
and a smile."

-- Robert Redford "Spy Game"
 
V

viraj

hi
when you want to pass control to some servlet first.. and then to
main.jsp.. you should have some URL like /controlServlet.do and map
this pattern to Controll servlet using web.xml

2) If the default page is not the servlet then how do I set it to be
the servlet "Control1"?
again.. use web.xml and same approach

3) How then do I pass on to a JSP to display? This also includes the
question of how do I make the JSP page available/visible to the
servlet?
you dont have to do anything to make it visible to servlet..
there are various way you can pass the control from servlet to jsp..
response.sendredirect for example

4) Within "mainPage.jsp" I want to collect info. How do I then pass
this info back to the servlet "Control1"?
again.. you will have to call that URL which is mapped to controll
servlet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top