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.

>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.

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.

See point 3 in this post for proper tutorial and avoid roseindia as plague

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.