java - is it correct to get html from servlet into ajax? -


i'm building web application has number of pages. index.html main page. has few <a> tabs each 1 links different servlet.

now, have general css design web app.

i want each web page received servlet have design.

the first idea had add css code top , bottom of servlet's response think code replication. next idea had receive servlet's response ajax, single div holds new page's content.

thank you

the reason jsps exist don't things this. returning html in java string cumbersome , error prone.

with jsp, can include different parts of other jsps. example, have jsp includes css links. can have jsps link it. here's info related that.

if want go further, use web framework. example, stripes framework easy use , has concept of "layouts". can use concept avoid dry violations more. allow avoid saying, "include header file" in every jsp can create.

and, there frameworks don't use jsps. example, wicket.

the 1 thing these web frameworks have in common avoid generating html directly in servlet. abstract details away more convenient construct.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -