Is it possible?
Can anyone give some examples?
In the case of an Excel spread sheet, of course the answer is 'no'. If you want to have your application serve multimedia content, like images, Excel spreadsheets, powerpoint presentations, music files, etc., then you need a separate servlet for this purpose. There is an article on the ServletsFaq page which talks about creating an image servlet for just such a purpose. You can see the article here: http://faq.javaranch.com/java/ImageServlet.
If I've misunderstood your request, please excuse me.
What does this data look like? What format is it?
anvi kon wrote:I want to import a file which contains all data not a image on a jsp page.
When you import into a JSP page, the content must be appropriate for the JSP page (HTML, text, etc.).
You can't just import an Excel spreadsheet.
Try providing more than a one line answer
You can include other JSP/HTML files using various flavors of the include tags. The best approach is to use the <c:import...> tag of the JSTL (Java Standard Tag Library).
However, the JSP has an include tag as well, <jsp:include ...> if you really don't want to use JSTL.
Note that the book: Core Servlets and JavaServer Pages has a chapter on including files in JSP pages. The book's chapters are available for free download from the book's website: http://pdf.coreservlets.com
You have never explained what you mean by this. What is the purpose of "importing" the file -- whatever you intend for that to mean? What is the outcome you are after?
anvi kon wrote:I want to know the approach to import a file.
You can't just plunk an Excel file in the middle of HTML and expect anything good to happen, so you need to put in the effort to explain what you want to do. Otherwise, you are just wasting your time and other people's time.
I would like to hava a button import on the web Page. If the user clicks the button import, he should be able to open the file (text/.xsl) and import all the data from (text/xsl) on the jsp page.
What would be the best way to do it?
Please help me with some suggestions or examples.
and import all the data from (text/xsl) on the jsp page.
Again -- what do you mean by this? As I said, you can't just embed the Excel file into HTML. Do you want it to replace the page? Do you want it to download to the user's system? Do you want it to open up in Excel? Or do you want to just import the data, and show it in an HTML table?
Just saying "I want to import the file" doesn't tell us what you mean by that.
When the user clicks the import button, where will the file be located which they wish to import? Will it be on their local computer?
If so, then the first part of your problem is to allow the user to upload the file to the server. See the FileUpload library from Apache Commons for help in doing this: http://commons.apache.org/fileupload/using.html.
If you then want to display this file on a web page, the way to do that depends on the format of the file. How you display a text file is different from how you would display an Excel spread sheet file (both are different from how you would display an Image or a music file, etc.).
You simply cannot create a page which can just display any type of file. You need to decide what types you wish to deal with, then implement the code necessary for each type. For example, you cannot simply serve the data from an Excel file in the middle of an HTML page. It will just look like garbage. There are ways, however, to serve non-HTML content. See the Image Servlet example in the ServletsFaq page for one way.
anvi kon wrote:Thanks for you'r reply.
I want to import the file from the location on the jsp page(HTML format).
Perhaps there's a language barrier here. What you wrote makes no sense to me at all. There is no file in the middle of a JSP page to import. Perhaps what you mean by "import" is different from what I am used to?
Given that you continue to supply the same meaningless one-line answers, I'm beginning to wonder whether you actually want any help.
Now that we finally know what you mean: