How to check files in the directory using JSP?.
Hi,
How can i check the file is directory or file and readable or writable and file size and type of file(Ex. jpg, txt, doc., etc). i want to list the specific type of file in the particular directroy.. please help me..
Regards
CHinna
With the File class, using the methods isFile(), isDirectory(), canRead(), canWrite(), length() and getName()
With File.listFiles() you can get a directory listing. If you want to limit the amount of files returned, you can pass your own FileFilter to it.
http://java.sun.com/javase/6/docs/api/java/io/File.html
Similar Messages
-
Determin how many user log on the site using JSP/Servlet?
Hi all,
Is there a way to determine how many user log on the site using JSP/Sevlet? I'm running Apache 2.x & Tomcat 4.x
I'm trying to get a list of user currently log in the site.
Please help!
Thanks,
-JN-You could use the HttpSessionBindingListener interface. Every time a user logs into the session put a user object into the session. The user object will implement the HttpSessionBindingListener interface. When the user object is added to a sessiion it recieves an event and it increments a counter. When the session times out or you invalidate the session because the user has logged out the user object will recieve an event and it can then decrement the counter.
This will at least tell how many active user sessions there are. -
How to write files on Client Machine using JSP
Hi,
I am new to JSP. Please tell me how do i write files on Client machine thru a Browser.
Please let me know at the Earliest.
Thanks.
Mehul Dave1) Well I find it rather convenient to deploy a web app as just one file rather than a bunch of files. For deployment it's much better. However I prefer using expanded files when developping (to use auto reload in Tomcat for example)
2) It is a bad idea to upload files inside your webapp's context (ie: in it's deployment directory) because one day an uninformed system administrator might come and redeploy the web app and therefore delete all your uploaded files (believe me, I've already experienced this!)
What i do usually is upload it in a completely different directory, something like /uploaded_files. Your uploaded files are therefore completely independant from your webapp
However it is a bit trickyer to get those files back. Let's take the example of image uploads. You have 2 ways of proceeding:
- the easiest : configure your web server (apache etc...) to redirect a certain url to your external directory. For example the /upload url will point to a /uploaded_files directory. This is easier to do and the fastest way to serve images but not always the best solution: you are dependant on the web server's configuration and you can't control the visibility on your files (no security constraints, anyone can see your uploaded files if they know the url).
- you can also write a servlet which will load the file as an array of bytes and send it back in the response.
You can call it this way :
<img src="/serlvets/showmyimage?path=uploaded.gif">
in this way you can control your uploaded files better: you may want to define security constraints on the visibity or not of uploaded files depending on the user which has logged on the site. -
How to store files in mysql database using JSP?
I'm developing an online recruitment system using JSP in server side. For the users who registers in it, I want them to upload their cv's from the web site so that I can store it in the database..I'm using mysql as the db..
Can I know how to do it.?..or else is there any better way of doing that?
Need a quick reply..TxThe best way to put data in a database in a JSP is to not do it. Instead, use a Servlet that calls a DataAccessObject. The DAO puts the data in the DB and the servlet gives the data to the DAO. The JSP does nothing but display results.
Take a google for JSP MVC and DAO. BalusC has a great example of DAO and a JSP that uses one on his blog. -
File upload and download using jsp/servlets
How to upload any file to the server using jsp/servlets. . Help me out
You can also try the Jenkov HTTP Multipart File Upload. It's a servlet filter that is easy to add to your web-project. After adding it, you can access both request parameters and the uploaded files easily. It's more transparent than Apache Commons File Upload. There is sufficient documentation to get you started, and there is a forum if you have any questions.
Jenkov HTTP Multipart File Upload is available under the Apache license, meaning its free to use. -
How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class? These are the keys,values: TreeMap The data I'd like to Cache is (date from the file, time of the file, current time).
import java.io.*;
public class CacheData {
public static void main(String[] args) throws IOException {
String target_dir = "C:\\Files";
String output = "C:\\Files\output.txt";
File dir = new File(target_dir);
File[] files = dir.listFiles();
// open the Printwriter before your loop
PrintWriter outputStream = new PrintWriter(output);
for (File textfiles : files) {
if (textfiles.isFile() && textfiles.getName().endsWith(".txt")) {
BufferedReader inputStream = null;
// close the outputstream after the loop
outputStream.close();
try {
inputStream = new BufferedReader(new FileReader(textfiles));
String line;
while ((line = inputStream.readLine()) != null) {
System.out.println(line);
// Write Content
outputStream.println(line);
} finally {
if (inputStream != null) {
inputStream.close();How can I Cache the data I'm reading from a collection of text files in a directory using a TreeMap? Currently my program reads the data from several text files in a directory and the saves that information in a text file called output.txt. I would like to cache this data in order to use it later. How can I do this using the TreeMap Class?
I don't understand your question.
If you don't know how to use TreeMap why do you think a TreeMap is the correct solution for what you want to do?
If you are just asking how to use TreeMap then there are PLENTY of tutorials on the internet and the Java API provides the methods that area available.
TreeMap (Java Platform SE 7 )
Are you sure you want a map and not a tree instead?
https://docs.oracle.com/javase/tutorial/uiswing/components/tree.html -
How can i add the check box beside the directory?
how can i add the check box beside the directory? anybody can help?
tis r the panel of my program :
// FileTreePanel.java
// JPanel for displaying file system contents in a JTree
// using a custom TreeModel.
package com.deitel.advjhtp1.mvc.tree.filesystem;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.*;
import javax.swing.event.*;
import com.deitel.advjhtp1.mvc.tree.filesystem.FileSystemModel;
public class FileTreePanel extends JPanel {
private JTree fileTree;
private FileSystemModel fileSystemModel;
private JTextArea fileDetailsTextArea;
public FileTreePanel( String directory )
fileDetailsTextArea = new JTextArea();
fileDetailsTextArea.setEditable( false );
fileSystemModel = new FileSystemModel(
new File( directory ) );
fileTree = new JTree( fileSystemModel );
fileTree.setEditable( true );
fileTree.addTreeSelectionListener(
new TreeSelectionListener() {
public void valueChanged(
TreeSelectionEvent event )
File file = ( File )
fileTree.getLastSelectedPathComponent();
fileDetailsTextArea.setText(
getFileDetails( file ) );
JSplitPane splitPane = new JSplitPane(
JSplitPane.HORIZONTAL_SPLIT, true,
new JScrollPane( fileTree ),
new JScrollPane( fileDetailsTextArea ) );
setLayout( new BorderLayout() );
add( splitPane, BorderLayout.NORTH );
JCheckBox check = new JCheckBox("Check me");
add( check, BorderLayout.SOUTH );
public Dimension getPreferredSize()
return new Dimension( 400, 200 );
private String getFileDetails( File file )
if ( file == null )
return "";
StringBuffer buffer = new StringBuffer();
buffer.append( "Name: " + file.getName() + "\n" );
buffer.append( "Path: " + file.getPath() + "\n" );
buffer.append( "Size: " + file.length() + "\n" );
return buffer.toString();
public static void main( String args[] )
if ( args.length != 1 )
System.err.println(
"Usage: java FileTreeFrame <path>" );
else {
JFrame frame = new JFrame( "JTree FileSystem Viewer" );
FileTreePanel treePanel = new FileTreePanel( args[ 0 ] );
frame.getContentPane().add( treePanel );
frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
frame.pack();
frame.setVisible( true );
}You can maybe explore button and forms feature in InDesign. It was added in CS6.
-
How to download a file from the internet using terminal
how to download a file from the internet using terminal
does any one know how to download afile from the internet using the Terminal application?Use curl. Something like this:
curl -O http://www.example.com/filename.zip
For more info, type +man curl+. -
Purchased a used macbook pro with Mountain Lion. My old Mac runs Snow Leopard is backed up to Time machine. How do I register the operating system to me and how do I use Time Machine to move my files to the new used computer?
If you look at the User Tips tab, you will find a write up on just this subject:
https://discussions.apple.com/docs/DOC-4053
The subject of buying/selling a Mac is quite complicated. Here is a guide to the steps involved. It is from the Seller's point of view, but easily read the other way too:
SELLING A MAC A
Internet Recovery, and Transferability of OS & iLife Apps
Selling an Old Mac:
• When selling an old Mac, the only OS that is legally transferable is the one that came preinstalled when the Mac was new. Selling a Mac with an upgraded OS isn't doing the new owner any favors. Attempting to do so will only result in headaches since the upgraded OS can't be registered by the new owner. If a clean install becomes necessary, they won't be able to do so and will be forced to install the original OS via Internet Recovery. Best to simply erase the drive and revert back to the original OS prior to selling any Mac.
• Additionally, upgrading the OS on a Mac you intend to sell means that you are leaving personally identifiable information on the Mac since the only way to upgrade the OS involves using your own AppleID to download the upgrade from the App Store. So there will be traces of your info and user account left behind. Again, best to erase the drive and revert to the original OS via Internet Recovery.
Internet Recovery:
• In the event that the OS has been upgraded to a newer version (i.e. Lion to Mountain Lion), Internet Recovery will offer the version of the OS that originally came with the Mac. So while booting to the Recovery Disk will show Mountain Lion as available for reinstall since that is the current version running, Internet Recovery, on the other hand, will only show Lion available since that was the OS shipped with that particular Mac.
• Though the Mac came with a particular version of Mac OS X, it appears that, when Internet Recovery is invoked, the most recent update of that version may be applied. (i.e. if the Mac originally came with 10.7.3, Internet Recovery may install a more recent update like 10.7.5)
iLife Apps:
• When the App Store is launched for the first time it will report that the iLife apps are available for the user to Accept under the Purchases section. The user will be required to enter their AppleID during the Acceptance process. From that point on the iLife apps will be tied to the AppleID used to Accept them. The user will be allowed to download the apps to other Macs they own if they wish using the same AppleID used to Accept them.
• Once Accepted on the new Mac, the iLife apps can not be transferred to any future owner when the Mac is sold. Attempting to use an AppleID after the apps have already been accepted using a different AppleID will result in the App Store reporting "These apps were already assigned to another Apple ID".
• It appears, however, that the iLife Apps do not automatically go to the first owner of the Mac. It's quite possible that the original owner, either by choice or neglect, never Accepted the iLife apps in the App Store. As a result, a future owner of the Mac may be able to successfully Accept the apps and retain them for themselves using their own AppleID. Bottom Line: Whoever Accepts the iLife apps first gets to keep them.
SELLING A MAC B
Follow these instructions step by step to prepare a Mac for sale:
Step One - Back up your data:
A. If you have any Virtual PCs shut them down. They cannot be in their "fast saved" state. They must be shut down from inside Windows.
B. Clone to an external drive using using Carbon Copy Cloner.
1. Open Carbon Copy Cloner.
2. Select the Source volume from the Select a source drop down menu on the left side.
3. Select the Destination volume from the Select a destination drop down menu on the right
side.
4. Click on the Clone button. If you are prompted about creating a clone of the Recovery HD be
sure to opt for that.
Destination means a freshly erased external backup drive. Source means the internal
startup drive.
Step Two - Prepare the machine for the new buyer:
1. De-authorize the computer in iTunes! De-authorize both iTunes and Audible accounts.
2, Remove any Open Firmware passwords or Firmware passwords.
3. Turn the brightness full up and volume nearly so.
4. Turn off File Vault, if enabled.
5. Disable iCloud, if enabled: See.What to do with iCloud before selling your computer
Step Three - Install a fresh OS:
A. Snow Leopard and earlier versions of OS X
1. Insert the original OS X install CD/DVD that came with your computer.
2. Restart the computer while holding down the C key to boot from the CD/DVD.
3. Select Disk Utility from the Utilities menu; repartition and reformat the internal hard drive.
Optionally, click on the Security button and set the Zero Data option to one-pass.
4. Install OS X.
5. Upon completion DO NOT restart the computer.
6. Shutdown the computer.
B. Lion and Mountain Lion (if pre-installed on the computer at purchase*)
Note: You will need an active Internet connection. I suggest using Ethernet if possible because
it is three times faster than wireless.
1. Restart the computer while holding down the COMMAND and R keys until the Mac OS X
Utilities window appears.
2. Select Disk Utility from the Mac OS X Utilities window and click on the Continue button.
3. After DU loads select your startup volume (usually Macintosh HD) from the left side list. Click
on the Erase tab in the DU main window.
4. Set the format type to Mac OS Extended (Journaled.) Optionally, click on the Security button
and set the Zero Data option to one-pass.
5. Click on the Erase button and wait until the process has completed.
6. Quit DU and return to the Mac OS X Utilities window.
7. Select Reinstall Lion/Mountain Lion and click on the Install button.
8. Upon completion shutdown the computer.
*If your computer came with Lion or Mountain Lion pre-installed then you are entitled to transfer your license once. If you purchased Lion or Mountain Lion from the App Store then you cannot transfer your license to another party. In the case of the latter you should install the original version of OS X that came with your computer. You need to repartition the hard drive as well as reformat it; this will assure that the Recovery HD partition is removed. See Step Three above. You may verify these requirements by reviewing your OS X Software License. -
How to check what is the full name of the installer is used?
Hi,
how to check what is the full name of the installer is used?
Thanks,Very nice, but assuming you did deliberately fire the installer, don't you remember the command? Apart from that your question has (as usual) no version and no platform and no context. If you are still in the installer and using any variant of Unix you can very easily run 'ps' to see the exact command.
You would have needed to provide platform and version information when submitting the SR. Can you explain why you have this forum guess at it?
Sybrand Bakker
Senior Oracle DBA -
How to store file into a directory?
i want to save the file(text file) into the directory which i have created using File object in the codes below. how do i do it?
public void saveString(String filename, String string)
//declare textfile to be null
PrintWriter textFile = null;
String line = null;
try {
// writes to write.txt
textFile = new PrintWriter (new FileWriter(filename,true));
line = string;
// save string in textfile
textFile.println(line);
textFile.close();
// create a directory (to store (output).xml file)
File fobj = new File("Testing");
fobj.mkdir();
catch (IOException e) {
System.out.println("Error in opening file");
System.exit(0);
}create the directory first and then create the file u want liek this
File f = new File (fobj,filename);
and then open the fiel to write like this
textFile = new PrintWriter (new FileWriter(f,true));
regards
rohan -
Store and Display doc/pdf files in the database using Forms
Hi all,
How can i store and display doc/pdf files in the database using Forms 10g?.
ArifHow to get up and running with WebUtil 1.06 included with Oracle Developer Suite 10.1.2.0.2 on a win32 platform
Solution
Assuming a fresh "Complete" install of Oracle Developer Suite 10.1.2.0.2,
here are steps to get a small test form running, using WebUtil 1.06.
Note: [OraHome] is used as an alias for your real oDS ORACLE_HOME.
Feel free to copy this note to a text editor, and do a global find/replace on
[OraHome] with your actual value (no trailing slash). Then it is easy to
copy/paste actual commands to be executed from the note copy.
1) Download http://prdownloads.sourceforge.net/jacob-project/jacob_18.zip
and extract to a temporary staging area. Do not attempt to use 1.7 or 1.9.
2) Copy or move jacob.jar and jacob.dll
[JacobStage] is the folder where you extracted Jacob, and will end in ...\jacob_18
cd [JacobStage]
copy jacob.jar [OraHome]\forms\java\.
copy jacob.dll [OraHome]\forms\webutil\.
The Jacob staging area is no longer needed, and may be deleted.
3) Sign frmwebutil.jar and jacob.jar
Open a DOS command prompt.
Add [OraHome]\jdk\bin to the PATH:
set PATH=[OraHome]\jdk\bin;%PATH%
Sign the files, and check the output for success:
[OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\frmwebutil.jar
[OraHome]\forms\webutil\sign_webutil [OraHome]\forms\java\jacob.jar
4) If you already have a schema in your RDBMS which contains the WebUtil stored code,
you may skip this step. Otherwise,
Create a schema to hold the WebUtil stored code, and privileges needed to
connect and create a stored package. Schema name "WEBUTIL" is recommended
for no reason other than consistency over the user base.
Open [OraHome]\forms\create_webutil_db.sql in a text editor, and delete or comment
out the EXIT statement, to be able to see whether the objects were created witout
errors.
Start SQL*Plus as SYSTEM, and issue:
CREATE USER webutil IDENTIFIED BY [password]
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp;
GRANT CONNECT, CREATE PROCEDURE, CREATE PUBLIC SYNONYM TO webutil;
CONNECT webutil/[password]@[connectstring]
@[OraHome]\forms\create_webutil_db.sql
-- Inspect SQL*Plus output for errors, and then
CREATE PUBLIC SYNONYM webutil_db FOR webutil.webutil_db;
Reconnect as SYSTEM, and issue:
grant execute on webutil_db to public;
5) Modify [OraHome]\forms\server\default.env, and append [OraHome]\jdk\jre\lib\rt.jar
to the CLASSPATH entry.
6) Start the OC4J instance
7) Start Forms Builder and connect to a schema in the RDBMS used in step (4).
Open webutil.pll, do a "Compile ALL" (shift-Control-K), and generate to PLX (Control-T).
It is important to generate the PLX, to avoid the FRM-40039 discussed in
Note 303682.1
If the PLX is not generated, the Webutil.pll library would have to be attached with
full path information to all forms wishing to use WebUtil. This is NOT recommended.
8) Create a new FMB.
Open webutil.olb, and Subclass (not Copy) the Webutil object to the form.
There is no need to Subclass the WebutilConfig object.
Attach the Webutil.pll Library, and remove the path.
Add an ON-LOGON trigger with the code
NULL;
to avoid having to connect to an RDBMS (optional).
Create a new button on a new canvas, with the code
show_webutil_information (TRUE);
in a WHEN-BUTTON-PRESSED trigger.
Compile the FMB to FMX, after doing a Compile-All (Shift-Control-K).
9) Under Edit->Preferences->Runtime in Forms Builder, click on "Reset to Default" if
the "Application Server URL" is empty.
Then append "?config=webutil" at the end, so you end up with a URL of the form
http://server:port/forms/frmservlet?config=webutil
10) Run your form.sarah -
How to pick files from ECC directory
Hi All,
I have to pick files from the directory of ECC. can anyone tell me how to configure the sender File apapter? Can i use NFS for the same?
Regards,
Lavanya RHi Lavanya,
With my knowledge two ways to pick the file from ECC using File adapter.
1. If you use NFS, mount point should be created in ECC for the Directory to access from PI.
2. If you use FTP, FTP ports must be opened between PI and ECC. -
How to check File size of a Text file.
How to check File size of a Text file.
please explain me.
I am new in LabVIEW. and dont have much idea on this...;
Prashant Soni
LabVIEW Engineer
Solved!
Go to Solution.Hi Prashant,
and here's what you get when using the LV help...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome -
Hi all,
I am dealing with checking file in certain directory path of the unix. If file can be found then has to be uploaded.
How to get list of those files in the unix and based on these information, I will do open dataset.
thanks alots.
AliaHi Alia,
Check this Function module also
call function 'SUBST_GET_FILE_LIST'
exporting
dirname = p_reqdir
filenm = ' '
tables
file_list = t_reqfile_list
exceptions
access_error = 1
others = 2.
This FM returns the list of all files in the path specified.
Regards,
Ravi
Maybe you are looking for
-
Hi carmen , The coding you have written above can be generated through code wizard easily. Just you need to click the code wizard button . just see the below link :- [http://help.sap.com/saphelp_tm70/helpdata/en/3b/29933f09a5fb47e10000000a114084
-
I created an Album with photos and matching music, but I realized I probably should have done this in SlideShow. Can i convert an album to a "slideshow" If so, how?
-
Import SMS with *.csv to Nokia6288
Hallo, i have exported all my SMS from a 6230 into a .csv file on my computer. Now I want to store the messages on my new 6288 but the Import button in the menu is disabled... Can someone help me? greetings Hasu0bs
-
Just sent in my daughter's Ipod touch 5th generation to be fixed.....They sent me a new one. Is there any way to get the contents of her old one onto the new one? I synced the old one with Itunes before I sent it in and backed it up on my computer.
-
Hi all, I use my user account on my MacBook to copy pictures from phone, camera etc. When we try to view them using another user account, we can see the thumbnails but can not run slideshows, etc. The first image appears as you would expect, but the