Sei sulla pagina 1di 16

issue is when are proving a concept

can we keep the code to the


"minimum" extent possible.
name of the game is how much details
you work out

context is super important.


as things become more detailed
people who only think will be in
asylum.
not only thinking, writing a must.
yesterday story.
1. how to create a web application in
ecclipse.

2. how to test by creating a simple


html.
3. servlet is a server side component
4. how to link servlet with the html
page.
5. doget and dopost.
4. role of HttpSErvletRequest,
HttpSErvletRsponse and
REquestDispatcher
--------------------------------output is not important, architecture is
important, becuase maintenance is
important and then comes importance
of getting product out.
without keeping maintenance mind,
then we "feel" architecture is adding
unnecessary complexity

in any web applciation


1. client will start with something X.
2. reach a servlet .
3. servlet will do some business logic
change, based on busienss logic status
4. client will see some change in the
presentation.
1 and 4 can be either html or jsp it
wont be anything else.
what is jsp.
jsp is server side web based
component which is used for
presentation .
html -- client side web based

component which is used for


presentation.
servlet
servlet is a server side component
which co -ordinates which incoming
requests and eventually enables
appropriate responses.
Web based Busienss logic
here is place where we read input
parameters got from the request and
we call the actual Service layer
from this place.
Jsp = html + lot of othr things .
lot of other things means

1. access to implicit objects.


request
response
session
...
2. ability to introduce dynamic content
via
custom tags
scriplets
expressions.
thru expression we can prin a variable
value.
<%= variablename %>
what is a scriplet
scriplet we can write some java code

which we typically write inside a


function.

so called plan
1. gi.html
textbox and submit button where user
a type a number.
2. action we will mention some jsp.
3. in the jsp, we will read the
parameter.
4. then use an scriplet and an
expresson to get our job done.

see the program

showmul.jsp and introduce a html


table in the program.
do the same program using servlet.
( idea is to show pain of servlet. -why servlet should not talk)
while writing scriplets be extra con....
in a html page, show two textboxes
in one textbox ask for a word
in another text box ask for a number.
in the jsp print the word as many
times as the user has asked for.

multiplicaton of two numbers.


we will show textboxes. if both
textbox
values are positive ie >1, only then we
will go a page called result.jsp and
show the multiplication result in all
other cases in the same page, next to
the textbox we will show a message
saying you have to give a value more
than 1.

which calcules of length of the string.


planning for the appliation
1. which page we plan to start from.
mulitply.jsp

2. what all input we will take from


the user, two values.
3. what is purpose.
tom
4. which is business logic class that
will do the checking reading
parametrs, doing business logic.
MultiplyWBL
5. what will this return, strings.
ok -- result.jsp
notok -- mulitply.jsp

to share information between web


based business logic and some server
side presentation component, we need
to use the notice board (scope
variables)

so called planning for word document.


a) where does request start from
word.jsp
in what all ways word.jsp can be
available.
1. directly -- word.jsp
2. when a textbox is empty
3. when a word has began with a

vowel.
b) what input parameter
word
c) what is purpose
tsl
d) Hello ( web based business logic)
e) what are status possible
ok -- result.jsp
we -- word.jsp (word empty)
hv -- wor.jsp (hate vowel)
notice board usage.
ok --k1 -- word -- String
--result.jsp
k2 --- length -- int -resultword.jsp
we -- k1 -- word is empty --

word.jsp
hv -- k1 -- word shouldnot start with
vowel. -- word.jsp
ew -- exisitng word
-- word.jsp
where are we goin to write
WBL
where are we going to read

-- String

we wrote to the notice board ok fine


but then first establish flow.
R1)
reg.jsp
we should have a textbox called userid
purpose -- tr
if userid textbox is empty, come back
to reg.jsp shwo a message that userid
cannot be empty.
if value of textbox is Hello or Hi or
Fine.
come back to reg.jsp and show a
message saying useid already taken
and ensure userid is retained in the
textbox.
in other cases go to pl.jsp

in pl.jsp welcome xxxx , here xxx


should be the userid .
-----------------------------------nr)
cw.jsp
have a textbox called s, purpose is nw.
if the textbox is empty then come
back to cw.jsp and show a message
saying textbox is empty.
if number of words in the textbox is
only one , again come back to cw.jsp
and show a message saying atleast 2
words shoud be entered.
in other case, go a page called cwr.jsp
print the sentence typed by user in
the textbox and also show the number
of words.

Potrebbero piacerti anche