Forums Register Login

load specified file to another JSP page

+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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!
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
Also, your include file contains <body> tags. This results in invalid HTML when it is included.
+Pie Number of slices to send: Send
 

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!
+Pie Number of slices to send: Send
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.
Weeds: because mother nature refuses to be your personal bitch. But this tiny ad is willing:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2713 times.
Similar Threads
Determine included JSP page name and load JSP into specified section using jQuery
Don't work some selectors into affablebean.css
Conditional include content
strut exception
ClassNotFoundException for JSP while upgrading to Tomcat 8
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:09:52.