Simple Me

Upload File from Struts2 then Put into a Folder

Sep 22, 2010 by Mila Yuliani

Actually, sometime if we want to upload file using Java Programming and Struts2 for the specific you used, you can follow my step to try it.....:)

After you upload that file, the file will put into .metadata folder from our project location be. likes a tmp file. it can read by us manually, but we must read it with read copy file of tmp file which can accessed by us. then it will make our easy to get the file which we needed.

in this blog, i want to write about how to step and may be it will handled if we want to put the file into a folder in our application web based.

Step to 'how to upload file use Struts2 and put into a folder' :

1. From our view(JSP, Velocity, HTML, etc) :

< form action="saveUpload.action" method="post" enctype="multipart/form-data" >

< table>

< tr>

< td> Upload File : < /td>

< td>< input type= " file " name=" upload ">< /td>

< /tr>

< /table>< /form>


2. Java Class will save into database for save uploadFileName and UploadContentType


public class SaveUpload extends ActionSupport{

protected File upload; // name of variable from view form

protected String docUploadFileName;

protected String docUploadContentType;

public String execute(){

    if(docUpload != null) {

           try {
//-------------- to put file into folder

        File file1 = docUpload;

        File file2 = new File(outPath+"/images/photo/"+docUploadFileName);

        String outPath = MyIO.getBaseFolder().getPath();

        InputStream in = new FileInputStream(file1);

//For Append the file.
//

      OutputStream out = new FileOutputStream(file2,true);

//For Overwrite the file.    

      OutputStream out = new FileOutputStream(file2);

      byte[] buf = new byte[1024];

      int len;

     while ((len = in.read(buf)) > 0){

          out.write(buf, 0, len);
}

     in.close();

   out.close();

//--------------this is to put data upload into database using hibernate

  employee.setDocUploadName(docUploadFileName);

  manager.save(employee);

} catch (IOException e) {

   e.printStackTrace();

}

return SUCCESS;
}
}

3. Class MyIO for putting path File Upload into /WebContent of our Application


public class MyIO {

public static File getBaseFolder() throws IOException {

       ProtectionDomain domain = MyIO.class.getProtectionDomain();

       CodeSource source = domain.getCodeSource();

       URL url = source.getLocation();

       if (!"file".equals(url.getProtocol())){

           throw new IOException("Code source location not a file:" + url);
}

      String path = url.getPath().replaceAll("", " " );

      return (new File(path.substring(0, path.lastIndexOf("/WEB-INF/" ))));

      }

}

then for displaying that image which we had putted into /WebContent we can access it easily.

4. View for Displaying the image


< table>

    < tr>

        < td colspan=2 align=right style="padding-top=10px">

          <img src="#surl("value=/images/photo/$!{employee.docUploadName}" )" border="1" height="150" width="130">

        </td>

    </tr>

    <tr>

         <td>Name</td>

         <td>: $!employee.name</td>

     </tr>

< / table>

then we can result of our code :

ok. it's so simple right?:)

thanks to: Home153179 

Setting Development Environment in WAS#1

Sep 01, 2010 by Mila Yuliani

WAS adalah singkatan dari WebSphere Application Server. Merupakan salah satu Application Server yang sering digunakan oleh para Developer J2EE atau pun Developer yang menggunakan Application Server WebSphere.

Nah, disini saya mencoba untuk membagi sedikit ilmu bagaimana men-setting Development Environment di WAS. berikut step-step yang harus dijalankan :

1. Install WebSphere Application Server (versi berapapun baik yang berbayar maupun yang versi Community)

2. Install Database(disini saya mencoba menggunakan DB2 sebagai Database)

3. Install IDE(Integrated Development Environment) untuk Development(bisa menggunakan Eclipse, Netbeans, AST, RAD, dll)

Ok, disini saya tidak akan mendeskripsikan step-step instalasi baik itu dari WAS sendiri maupun dari IDE yang digunakan. karena ini dianggap sangat mudah..:)

Setelah meng-install WAS dan IDE yang digunakan maka kita harus membuat profiles di IDE tersebut untuk men-setting Aplikasi kita dalam hal ini saya menggunakan Application Server Toolkit sebagai IDE.

step-step nya sebagai berikut :

1. Pada AST klik Window -> Preferences -> Server -> WebSphere -> Create

2. Setelah ini akan muncul tampilan sbb :


3. Kemudian Pilih Next dan akan muncul tampilan sbb :

4. Kemudian pilih Next akan tampil sbb :

5. Pilih Advanced Profile creation dan klik Next untuk melanjutkan dan akan muncul tampilan sbb :


6. Pilih Deploy the Administrative console(Recommended), dan akan muncul tampilan sbb:

 

7. Kemudian klik Next untuk melanjutkan dan akan tampil sbb:

8. Masukkan Node dan Host kita dimana Node itu adalah nama dari Profile Computer Name kita. kemudian klik Next untuk melanjutkan, dan akan muncul tampilan sbb:

9. Masukkan user name dan password pada saat kita meng-installasi WAS. kemudian klik Next dan akan muncul tampilan sbb :

10. Berikut keterangan dari port yang digunakan untuk mengakses Application maupun Administrative Console dari WAS. klik next dan Create

Ok segitu dulu deh, udah di uber-uber waktu nih. next blog yaitu bagaimana kita meng-configure Database dengan Administrative Console di WebSphere menggunakan Datasource...:)

 

Hopefully the best

Exclude List for JSP Reload

Aug 25, 2010 by Mila Yuliani

Cukup simple juga, ketika sebuah aplikasi running dan kita mendapatkan perubahan pada View khususnya JSP maupun view yang lainnya, kita diharuskan untuk me-restart aplikasi server kita. supaya perubahan dapat ditampilkan di browser(khusus untuk Web Application). nah agar kita tidak selalu me-restart aplikasi server kita, disini saya membuat sebuah konfigurasi kecil yang mengambil dari fungsi DOS xcopy, untuk kali ini saya menggunakan windows sebagai Operating System. dan berfungsi untuk me-reload sebuah view tanpa kita harus me-restart aplikasi server di setiap perubahan pada jsp, velocity,dll.


Langkah-langkah nya yaitu :


1. Pada IDE(Eclipse) Klik Run -> External Tools -> External Tools kemudian akan tampil sbb:


2. Klik New pada Program kemudian ketikkan Nama di 'Name'


3. Untuk Location masukkan URL Path untuk program DOS xcopy.exe


C:\WINDOWS\system32\xcopy.exe



4. Working Directory : diisi workspace directory yang akan kita copy


${workspace_loc:/bnkweb-bb/WebContent/WEB-INF}


5. Arguments : berisi perintah untuk xcopy dari Workspace ke InstalledApps atau metadata file yang di deploy oleh Aplikasi Server.


D:\dev\S137R1\environment\product\j2ee\ear\modules\bnkweb-bb\WebContent\WEB-INF\*.*
D:\dev\ws\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\bnkweb-bb\WEB-INF  /E/C /H /R /Y /Z /EXCLUDE:D:\dev\excludeList.txt


Context Syntax : <Workspace Directory> <metadata Directory> /EXCLUDE: <File Exclude List>


adapun isi dari Exclude List file berupa :
\.svn\
.jpg
.gif
.png
.css
\.js\
.swf

HTML5

Aug 17, 2010 by Mila Yuliani

HTML singkatan dari Hyper Text Markup Language. HTML versi terbaru yaitu HTML5 yang banyak digunakan pada Pemrograman Mobile sekarang ini.

Apa yang baru dari HTML5?

<header></header>, <section></section>,<label for=""></label>, <footer></footer>, dll.

Apa fitur yang tersedia di HTML5?

1. Drag and Drop

2. Edit Content

3. Storage Offline, dll

Berikut saya buat sample dari HTML5 dan Compare dari HTML4 yang sangat familiar dengan kehidupan kita sehari-hari..;)

HTML5

<header><h1>Sample Form</h1></header>

<form><label for=""contact_name"">Name:</label>
<input id=""contact_name"" placeholder=""Enter" your="" name"="" autofocus="" />
<label for=""contact_email"">E-mail:</label>
<input id=""contact_email"" placeholder=""Enter" your="" email="" address"="" type=""email"" /> 
<label for=""contact_phone"">Phone:</label>
<input id=""contact_phone"" placeholder=""Enter" your="" phone="" number"="" type=""tel"" />
<input value=""Submit"" type=""submit"" />
</form>

 

hasilnya akan nampak seperti berikut ini :


Sample Form








Sekarang kita Compare dengan HTML4 

<h1>Sample Form</h1>
<table>
<tr>
<td>Name</td>
<td>: <input name=""name"" type=""text"" /></td>
</tr><tr>
<td>E-Mail</td>
<td>: <input name=""email"" type=""text"" /></td>
</tr><tr>
<td>Phone</td><td>: <input name=""phone"" type=""text"" /></td>
</tr><tr>
<td><'input value=""Submit"" type=""submit"" /'></td>
</tr>
</table>

 

Dapat kita lihat hasilnya seperti ini :


Sample Form

Name:
E-Mail:
Phone:

Kita dapat melihat perbedaannya, dimana pada HTML5 dengan menggunakan <input type=""namavar"" /> akan membuat sebuah textfield dibandingkan dengan jika kita membuat textfield pada HTML4 yang harus mendefinisikan <input name=""namavar"" type=""text"" />..so? keep easy with the new other.

Hopefully the best,

MY

OOP#5 Looping Control

Aug 15, 2010 by Mila Yuliani

Looping Control i think same with Structure Control which one of Basic Programming in every Programming Language. yeah let us remembering about it.

1. While
    Context Syntax to loop use While :

int a = 0;
while(a<=10){
    System.out.print(a);
    a++;
}

 

output of that code:
012345678910

2. Do-While
   
Like with While syntax, do-while is used for looping too. but different context with other syntax. and it will do first statement in branch of do before while.

int a = 0;
do{
    System.out.print(a);
    a++;
}while(a<=10);

3. For
    Mostly every one always using "for" for looping. cause it's so simple to make it.

int a;
for(a=0; a<=10; a++){
    System.out.print(a);
}


Count & Count IF on Formula

Aug 11, 2010 by Mila Yuliani

I think i get new lesson tomorrow, yeah. i get this is from the defect logs in my office. it is very simple but it is very useful lets me to tell about this.
sometimes people will count all of that their countable condition likes all amount student in their school who passed an exam, or may be just countable some agree choice in their office who attend in a meeting to get a voice voting. yeah just like that..:)
ok lets see the sample one :

Person AttendAgreeNot Agree
ABCDV
FGH
V
IJKL
V
MNOV
PQRV
STUV
VWXV
YZV
Total Voter8
Agree6
Not Agree2

yeah, with the Formula Excel Sheet we can see :
1. Total Voter : =counta(B2:C9)
2. Agree : =countif(B2:B9;"V";)
3. Not Agree : =countif(C2:C9;"V";)

it is will come if we just one sheet condition. so, how to make a sample like that but we just take all of sheet in a workbook like a summary. yeah. we just put link to point to all sheet in a workbook. lets see :

Agree6
Not Agree2

if we put sample above in a Sheet2 and we want to put some summary in Sheet1 so, we put in Sheet1 "Agree" likes : =Sheet2!C$11 and "Not Agree" likes : =Sheet2!C$12.

hopefully the best..

OOP#4 Structure Control

Aug 11, 2010 by Mila Yuliani

Structure Control in Java Programming is used for controlling statement if the value have an True or False condition. Structure Control like:

1. If-Else
    If-Else commonly is used for making a condition statement control in Java Programming. and mostly every Programmer know about it. right?
this is the context syntax which can give you a reason "why must use if-else?".hehehe..:)

if(statement){
    statement1;
}else {
    statement2;
}

2. Switch-Case

    Switch-Case is alternative for making a condition statement control in every programming language. mostly another programming language have it. but different context syntax with Java Programming and other. this is the context syntax from Java Programming :

switch(switchexpression){
     case selector1:
           statement1;
           break;
    default :
           statement2;
}

OOP#3 Operator

Aug 10, 2010 by Mila Yuliani

Operator in Java Programming to make some statement is correct. Java Programming have many Operator there. like :

1. Aritmatic
    Aritmatic Operator is one way for doing some mathematic operation.like : +,-,/,x.

2. Increment & Decrement
    Increment & Decrement Operator is used for increment or decrement some variable integer or else. like : ++,--.

3. Relation
    Relation Operator is used for increment & decrement statement like "more than equals" or another. like : <=,>=,<,>,==,!=.

4. Logic
    Logic Operator is used for make a condition correct of boolean type. i think last time in my blog have a Algorithm Boolean and give some statement for get a correct answer and probably will hapen. like : True, False.

5. Condition Statement
    Condition Operator i think it same with conditional statement in java programming. like : conditionStatement?true:false;
let's see the sample below :

int nilai = 70;
String status = (nilai>=60)?"Passed":"Failed";


6. Precedence
    Precedence Operator is a therminology think for do the first and last operation will do by computer. hehehe.. last time, my friends who internship in my office got the examination of internship. and then i put some precedence operator there. but no one can answer right: let's see :
if i have a sample precedence operator like this:3*10*2/15-2+4^2^2

what is in your mind?

in my mind is 6 why? see the syntax here : computer will do the operation first with /,x,+,-. right?
so, this answer is : (((3*10*2)/15)-2+(4^2^2)) = 60/15-2+4. this is simple when we do divide first:)
then what the answer for : 6%3*5+4/2+88-10?

OOP#2 System.out.println() is different

Aug 10, 2010 by Mila Yuliani

yeah..i think all of the people can difference what is System.out.println() and System.out.print() just remember it again. System.out.println() will display all of the statement in "(statementhere)" with a new line, but System.out.print() won't display with a new line. i mean it's not a problem for us, for make a new line or no. just follow that step, if you want to make a new line so, use "System.out.println()" or if no to new line just use "System.out.print()"..:)
let's see the sample code below :

public static void main(String[]args){
     System.out.println("Hello");
     System.out.println("World!\n");
     System.out.print("Hello");
     System.out.print("World");
}

this is the output :
Hello
World!
HelloWorld


OOP#1 Variable

Aug 10, 2010 by Mila Yuliani

Variable is an item which can use to instate some statement or else in object oriented programming. not for java programming but for another programming language i think.

<data type><name>[=initial value];

yeah, this above the context syntax to make a variable. let's see the sample below :

String nama = "mila yuliani";
Char namaa = "M";
int intnama = 10;
double grade = 0.0;

is it simple right?enjoy!!

Start with F8

Jul 30, 2010 by Mila Yuliani


When i give the reason "why i can't blogging for a while?" to my "B*ss" in his car, then he talk to me to "Gaul dong!!"hehehe.. just find some issue with me?
yeah. actually just a dizzy people who can give a reason. uh, this very bad!:O
i find some solve for my problem, when i can't get an internet connection last time. i start with F8 in my browser, yeah, this is for opening the ScribeFire which can make me easy to written for my blogging. hehehe..


ScribeFire is an adds for Mozilla Firefox. yeah it's a blog editor same with blog editor in our blog when we access like wordpress, blogspot, roller and other one.
After we installed Adds the name is "ScribeFire" then the browser will
ask for restarting that browser. and after restart that browser so, we
just listen F8 for starting with ScribeFire.


so now, not reason to me to not a blogging..hahaha..
when the time is difficult to get something, but i think many way to do something what we looking for it. so, just find the simple think for making life the best..:)
this screen capture when i written my blog in ScribeFire..


Algoritma Boolean

Jun 09, 2010 by Mila Yuliani

Algoritma adalah suatu teknik logika yang dijadikan sebagai jalan pintas untuk memecahkan suatu masalah didalam pemrograman khususnya.

Algoritma Boolean adalah metode logika kebenaran tentang suatu fakta pemecahan suatu masalah. Algoritma Boolean diperlukan untuk mengetahui dominan tabel kebenaran maupun kesalahan dari suatu masalah.

Misal :

a : hari ini hujan

b : jalan becek

maka akan menjadi tabel kebenaran jika :

"hari ini hujan dan jalan becek" atau

"hari ini hujan atau jalan tidak becek" atau

"hari ini tidak hujan atau jalan becek"

banyak kemungkinan yang didapat dari hasil perbandingan tabel kebenaran:

tinggal disesuaikan dengan context masalah yang dihadapi...;)

hopefully better...


w.a.l.k around

May 24, 2010 by Mila Yuliani

let's begin......

this is twice for walking around in the world.*amin* 

first i take this trip from Yogyakarta. Meruvian Yogyakarta was attend a training event. i and my friend go there for attending it. Yogyakarta is one of Special City in indonesia which i have visited. yeah. although just a week from there, but i'm so happy because that city is firstly i want to visit when i'm visiting another city in indonesia. yeah. that only my Meruvian has realize that my dream.

I think and always thinking about it. when my dream. all my dream will come true soonly.

second, and now, i'm in Sukabumi. this twice for me to attend again for my stuff. i really have fun for doing this work. may be it's so difficult to remember that i want to walk around in the world. hehehe..:)

hopefully better in my life and be the best.:)

cheers

Subversion

May 15, 2010 by Mila Yuliani

Subversion is one of versioning for commiting project to internet/local server. that's mean subversion is used for uploading code from local computer to internet/local server to make easy to team work.

may be it's familiar word of programmer who works from Information and Technology fields.it used to commit or checkout from source in the internet/local server. and it makes their easily when they are download manually from internet, and it makes easy to get it.

many kind of versioning from programming especially JAVA programming. as CVS, git, gh,etc. in this topic i will share about how to subversion work, how to install subclipse for support to subversion and how to commit and checkout from subversion. ok let's begin.

1. how to subversion work

subversion can work when it has installed from our computer. subversion can work under eclipse, turtoiseSVN from windows, and console from internet. many way to access subversion client. yah, it's only subversion client different with subversion server. subversion server called SVN Admin. it's can save the source to a repository server like a node(*from JCR).

2. how to install subversion

I was talk about subversion client which will be used by us for commit or checkout source from another computer or another server. first, we must have subversion client for getting it. but, when people not want to preoccupied with their job. it can be alternatively when access SVN Client. using eclipse.

Step to install SVN Client using Subclipse(Plugins Client for eclipse) :

this link to install subclipse as plugins from eclipse as IDE(klik here)

when we have installed subclipse then we must restart eclipse to use subversion

3. how to use subversion

Many features from Subversion i think i just know for developing in a team work which can make our develop is synchronize with another people in our team. so, what it can be used by us?

  • Checkout : checkout is using for get source code from local server/internet to local computer.
  • Commit : when checkout has finished, next step must we do is commit.yeah. it is for share project to another computer or uploading to internet.
  • Update : it use for updating some code to another computer SVN Server. and it is can work well when the code which commit for updating is synchronize with the code from server.
  • Synchronize : is used for synchronizing source code which different and it will get red color when conflict source code.

we can use subversion as :

1. right click project will be shared to another

2. choose Team -> Share project and then will display this dialog box :

 

3.  then choose SVN and will display this dialog box :

 

4. Create new Repository Location which SVN will be placed. and will display this show :

Click OK to complete this commit and will display process dialog box until finish commit the project.

that's it.

keep trial and error, it make our perfect. hopefully better

The 5th'S for Our Daily Activities

Apr 22, 2010 by Mila Yuliani

Sering kita melupakan hal-hal sepele yang sangat berpengaruh untuk kehidupan kita. Menganggap semuanya mudah. sehingga, untuk menjadikan diri yang teratur dan disiplin sangatlah sulit jika kita tidak memulainya dari 5 hal berikut : 

1. Seiri (Sort / mengurutkan)

Kita harus memisahkan benda-benda yang dibutuhkan dan menghilangkan benda-benda yang tidak dibutuhkan di sekitar kita. dalam hal ini membantu untuk memberikan ketentraman dan kenyamanan didalam kita bekerja.

2. Seiton (Rapi / terstruktur)

Menempatkan sesusatu ditempatnya. misal menyimpan barang-barang yang diperlukan untuk pekerjaan pada tempat yang diketahui keberadaannya. sehingga memudahkan kita dalam pengambilan barang tersebut ketika kita membutuhkannya.

3. Seiso (Bersih, Rapi)

Kebersihan tempat kerja dapat meningkatkan mood pada saat bekerja. sehingga, kita harus dapat menjaga kebersihan dan kerapihan tempat kerja kita. me-rapi-kan tempat kerja sebelum dan sesudah melakukan sebuah pekerjaan atau task.

4. Seiketsu (Standarisasi)

Melakukan standarisasi terhadap Seiri, Seiton dan Seiso. kita bisa menjaga sikap kita dan aktivitas yang kita punya menjadi lebih teratur.

5. Shitsuke (Membiasakan diri untuk disiplin)

Membiasakan diri untuk dapat hidup disiplin dan teratur. setiap orang mempunyai standard kedisiplinan pribadinya masing-masing. so, klo misal kita mempunyai standard tersebut, kenapa kita tidak berusaha untuk dapat mengikutinya...?!

5S ini merupakan teori yang sudah sangat berjalan di negeri matahari terbit sana. dari kata-katanya pun semua serapan dari nihongo. ii deshou. ja mata.

Source : Fotocopy 5S yang ada di binder...:) daripada ilang lebih baik di blogging aja..;)

Search

 

« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today

Links

Feeds

Navigation