• Post Reply Bookmark Topic Watch Topic
  • New Topic

load specified file to another JSP page  RSS feed

 
Alex Tom
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,
i'm working on a web project. now i want to load my login.jsp into main.jsp while clicking a button in status.jsp, which is included by main.jsp:

main.jsp:<body>
<div id="container">
<div id="banner" align="center" style="margin:auto; height:141px">
<img alt="XXXX" src="images/banner.jpg"></img>
</div>
<div id="navigation" style="width:420px; height:50px;float:left">
<jsp:include page="frame/navigation.jsp"></jsp:include>
</div>
<div id="status" style="width:444px;height:50px;float:left">
<jsp:include page="frame/status.jsp"></jsp:include>
</div>

<hr />
<div id="menu" style="width:164px; height:400px;float:left">
<jsp:include page="frame/menu.jsp"></jsp:include>
</div>
<div id="content" style="width:700px; height:400px; float:left">
<jsp:include page="frame/content.jsp"></jsp:include>
</div>

<hr />
<div id="footer" style="text-align:center">
<jsp:include page="frame/footer.jsp"></jsp:include>
</div>
</div>
</body>

status.jsp:
<body onload="showTime()">
<%
User user = (User)session.getAttribute("currentUser");
if (user != null) {
String name = user.getUsers_realname();
%>
<div>Welcome,<%=name %>!  <input type="button" name="logout" value="Exit" onclick=""></div>
<%
} else {
%>
<div style="color:red">You haven't loggod on, please<a id="login" href="#">login</a></div>
<%
}
%>
<label id="curTime"></label>
</body>

HERE, while clicking "login" link in satus.jsp, which has been included in main.jsp,
my login.jsp will be loaded into content.jsp, which is also part of main.jsp ,
so how can i do this? Thanks in advance!
 
Alex Tom
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any idea?

my opinion is, notify one page to load another page,
to do this, i need a function loadPage taking three parameters, similar to the load() function of jQuery



file -- the file to be notified to load the specified file (url), for example, main.jsp in this post
id -- the identifer in the previous parameter, for example, "content" in main.jsp
url -- the file to be loaded, for example, login.jsp in this post

my question is, how can i implement this function? thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Without code tags your code is hard to decipher. I tried to add code tags for you, but there were so many color tags mixed in, I just gave up. In future posts, I'd advise you to avoid color and UseCodeTags.

If you want the functionality of the jQuery load() function, why not use the jQuery load() function?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, your include file contains <body> tags. This results in invalid HTML when it is included.
 
Alex Tom
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Without code tags your code is hard to decipher. I tried to add code tags for you, but there were so many color tags mixed in, I just gave up. In future posts, I'd advise you to avoid color and UseCodeTags.

If you want the functionality of the jQuery load() function, why not use the jQuery load() function?



thanks for your advice.
as a newbie, i don't know how to use load() function in this example, could you help me? thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to load the HTML as the result of a user action such as a button click, that's not something you'd do with a JSP include (which executes on the server before the page is even sent to the browser).

jQuery's load() method, used in a handler for the click event, is the way to go.

If you don't know how to use JavaScript or jQuery, then you'll need to find some tutorials or read some books. You're not going to learn two complex technology in a forum post.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!