I have login button in the left side of the web page, now I want this to be available at any page in my site, however I don't want to reload the whole page all the time, when the user login I want to keep his name constant on the left side which is there for the all site.
I want to avoid frameset this is realy problematic for my site.
The site id built with JSP.
what are the options.
I thought of using <jsp:include page=''>
and try to change the page url dynamicly but this is impossible since it is compiled to servlet and this it server side.
Also if I include leftSide.jsp in each page than leftSide does reload for every page. please advice, 开发者_StackOverflowthere must be a solution for this simple and very common problem.
- You can use
<%@ include file="login.jsp" %>
in all pages. The login.jsp can contain the common code - You can use a template engine, like tiles, freemarker or sitemesh.
With either of these, if you don't want to reload, you need ajax. Perhaps using jQuery.
- call the login/logout server-side action using ajax
- update the box (make it a
<div>
) accordingly, with javascript
精彩评论