0

Hi, everybody.
i want to get file name from html file input form using jsp.

my codes are followed as:

<table>
        <tr>
            <td >
             <input type="file" id="csvfilebrowse" name="csvfilebrowse" value="" width="400px" style="width:400px; height:20px" onChange="getcsvfilename();"> 
             
			<script type="text/javascript">
            // <![CDATA[
            
            function getcsvfilename() {
                var v_csvfileName = '';
                v_csvfileName += document.getElementById('csvfilebrowse').value;
			
				getCSVFileContents(v_csvfileName);
            };
         // ]]>
            </script>
          </td>
            
        </tr>
        <tr>
            <td align="left">
				<%	
					Workbook workbook = null;
					Sheet sheet = null;
					String csvFileName = v_csvfileName;
					// Reading Test
					 
					workbook = Workbook.getWorkbook(new File(csvFileName)); 
					sheet = workbook.getSheet(0); 
					for(int i=0;i<sheet.getColumns();i++){
						Cell a1 = sheet.getCell(i,0); 
						String $stringa1 = a1.getContents(); 
					}
              	%>
            </td>
        </tr>
    </table>

here, what i want to get, how to convert the filename variable named v_csvfileName of javascript to the filename named csvFileName of jsp.

who can help me?
probably, there can be several method.

please kindly teach me.

thank you.

3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by peter_budo
0

>what i want to get, how to convert the filename variable named v_csvfileName of javascript to the filename named csvFileName of jsp.

No. JSP runs on the serverside and Javascript runs on the client side in the web browser. JSP can generate javascript code onto the page, but the only way javascript can communicate with JSP is to make a web request.

>i want to get file name from html file input form using jsp.

You need to upload a file.

0

hi Mr, adatapost.
thank you for ur kindness reply.

i read the contents you indicated.
l also know that what i need is similar to the file uploading through the uploading sample
but this sample uses the two jsp file
i want to implement this in one same jsp page.
as i am primary student on jsp, it is difficult to understand it for me
if you have any idea, can you detail about that?

thank you so much.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.