File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes including a file in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "including a file in jsp" Watch "including a file in jsp" New topic

including a file in jsp

Muhammad Imad Qureshi
Ranch Hand

Joined: Sep 13, 2005
Posts: 238
I am including a jsp inside one of my jsps as follows

<form method="post">
......some code
<%@ include file="addressFind.jsp" %>
.....some more code

now in my javascript function when I say document.forms[0].element then it gets the form from addressFind.jsp and not the current form. and when i say document.forms[1].element then it says forms[1] has no properties. How can I include the file and still be able to access my current form. This page is a popup page.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

If you are including a form within another form then you are generating invalid HTML. It has nothing to do with the include -- the same thing would happen if you didn't use the include and generated an HTML file with a form within a form.

Remember, JSP is just a templating technology to generate the HTML page to send to the browser. It's your repsonsibility to ensure that the HTML that gets generated is valid.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: including a file in jsp
It's not a secret anymore!