Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i get the path using browse dialog box in jsp 1

Status
Not open for further replies.

jollyplay

Programmer
Dec 16, 2003
90
Hi

In my JSP I am having a text box and a browse button. When I click the browse button the browse dialog is to be displayed and the path selected is displayed in the text box. I dont know how to display the browse dialog box in jsp. Plese provide me a link or code for this.

Thanks in advance.
 
Hi thanks.
I have to select the directory where to save the file.
If we use <input type=file> it display the open dialog box to open the file. Using that we can get the path of the file selected in the text box.

Help me.
 
I am exporting the data from the database table to the path specified by the user.

For example I'm having a table named "employee". I have to export the data from the table employee using "SELECT * INTO OUTFILE 'path' FIELDS TERMINATED BY ',' FROM employee"

In the query I have to specify the path. Thats why I have to get the path from user. If I get the path specified by the user in the text box I can pass it to the query. Please give to me some solution. I'm sticking to this pbm for a long time. Kindly help me.

Thanks.
 
Where the user clicks to open a file does not matter one bit - you are exporting data from a server to a client - you have NO control on where or what the user does which that data- hence the fact that whereever the browse dialog path may be, it means nothing to you.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Hi,

You have to do some thing like this, coz you cannot copy the file from server to client.

Your jsp should be some thing like this Change the red color line and get the Database connection.
Code:
<%@ page import="java.sql.*"%>
<%
//[COLOR=red]change the context type to csv and file name as well[/color]
  response.setContentType("application/html.ms-excel"); 
  String aFileName = "SQLReport.xls"; 
  response.setHeader("Content-disposition", "attachment; filename=" + aFileName);
  //[COLOR=red]Get the Database Connection 
  Connection connection = DBUtil.getOracleConnection();
  [/color]
  // Create a result set
  Statement stmt = connection.createStatement();
  ResultSet rs = stmt.executeQuery("SELECT * FROM EMPLOYEE");
  ResultSetMetaData rsmd = rs.getMetaData();
  int numColumns = rsmd.getColumnCount();
  
%>
<html>
  <head>
    <title>untitled</title>
  </head>
  <body>
    <table cellspacing="2" cellpadding="3" border="0" width="100%">
      <tr>
        <%
         for (int i=1; i< numColumns+1; i++){
         String columnName = rsmd.getColumnName(i);
        %>
        <td><%=columnName%></td>
       <%}%>
      </tr>
      <%
        while(rs.next()){%>
        <tr>
        <%for(int i=1;i<=numColumns;i++) {%>
        <td><%=rs.getString(i)%><%}%>
        </td>
       <%}%>
       </tr>
    </table>
  </body>
  <%connection.close();%>
</html>

Hope this will hlep you

Cheers
Venu
 
Thank you very much Mr.venu. Its working. Thank you so much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top