Hi, Is there any way for a servlet to connect to a database, other than connecting through a JDBC-ODBC? Is it possible for a servlet to download a file, if so, how can it download? Any one can, please help me. Neelima
A servlet can do any kind of database connection that any Java application can do. JDBC just happens to be the easiest approach. A servlet can transmit any kind of file that you might get from a normal web server, you just have to set the content headers correctly to reflect the file type, size, etc. My Java Developer's guide to servlets and JSP - which should be available shortly - has examples. Bill
i think a better approach is 2 use beans ... bcos u could make is once, coding all ur jdbc functionality ... and can use it again and again .... beans r good for servlets but they r best for JSP if u dont want 2 show ur database 2 ur web page designer ... mannubaba
Joined: Nov 22, 2008
i was told by my teacher to always use type4 drivers when workin on or for the web, so u can forget jdbc-odbc stuff here. oracle is shipped with its own jdbc driver, for msSQL server u can download one from www.inetsoftware.com the driver name is SPRINTA, go n check it, its cool n will help u with ur stuff. adios
Hey, here's a neat trick when you're trying to download a file from a servlet: If your normal servlet path is "/servlet/Download", try pointing the browser to "/servlet/Download/the_file.exe" instead. The request will still get directed to your servlet just like before, but now the browser will be expecting an .exe file (and the user will be able to save the file you give them by that name). You should still set the MIME type correctly, but this basically ensures that the browser will know what it's getting (filename seems to take priority over MIME type).