https://dololak.tistory.com/502

'For developer > Servlet&JSP' 카테고리의 다른 글

(Web.xml)Mapping 수동설정 하는 법  (0) 2020.05.12
Java EE 개발환경 구축  (0) 2020.05.11
- Servlet Mapping(수동설정) : WebContent > WEB-INF > web.xml
		<!-- Servlet Class 정의 -->
	  		<servlet>
	  			<display-name>Servlet Class Name</display-name>
	  			<servlet-name>Servlet Class Name</servlet-name>
	  			<servlet-class>Package.Servlet Class Name</servlet-class>
	  		</servlet>
	  	<!-- Servlet Mapping 설정 -->
	  		<servlet-mapping>
	  			<servlet-name>Servlet Class Name</servlet-name>
	  			<url-pattern>/xx.do</url-pattern>
	  		</servlet-mapping>

 

'For developer > Servlet&JSP' 카테고리의 다른 글

(Servlet)requestDispatcher  (0) 2020.05.12
Java EE 개발환경 구축  (0) 2020.05.11
btnMain.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();

            }
       
        });

 

package com.example.my01_helloworld;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

Button btnCall,btnNew;
EditText etPhoneNum;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

etPhoneNum = findViewById(R.id.etPhoneNum);
btnCall = findViewById(R.id.btnCall);
btnCall.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String phoneNum = "tel:"+etPhoneNum.getText().toString();

Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse(phoneNum));
startActivity(intent);
}
});

btnNew = findViewById(R.id.btnNew);
btnNew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),Sub1Activity.class);
startActivity(intent);
}
});

}

public void btn1Clicked(View view){
Toast.makeText(this, "버튼1클릭!!!", Toast.LENGTH_SHORT).show();
}

public void btn2Clicked(View view){
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://m.naver.com"));
startActivity(intent);
}
}

 

 

 

public class Ex_String02 {
	//문자열의 대소관계 비교(compareTo(), compareToIgnoreCase())
	//동등관계 비교(equals(), equalsIgnoreCase())
	public static void main(String[] args) {
		String str1 = "APPLE";
		String str2 = "ORANGE";
		String str3 = "APPLE";
		String str4 = "apple";
		
		//if(str1 > str2)▶ 오류 : 문자열의 대소관계는 비교연산자를 사용할 수 없다.
		//문자열의 비교는 유니코드 값으로 비교한다 ▶ compareTo()
		//compareTo() 결과 : 양수, 0, 음수
		int result = str1.compareTo(str2);
		System.out.println(result);		//-14(음수) : str2가 더 크다
		
		result = str1.compareTo(str3);
		System.out.println(result);		//0 : str1과 str2는 같다
		
		result = str4.compareTo(str1);
		System.out.println(result);		//32(양수) : str4가 더 크다
		
		result = str1.compareToIgnoreCase(str4);	//대소문자 구분없이 비교
		System.out.println(result);		//0 : str1과 str4는 같다
		
		//문자열이 같은지 다른지(동등관계)를 판단 ▶ if(str1.compareTo(str2) == 0)
		if(str1.equals(str2)) {			//equals() : true, false 반환
			System.out.println(str1 + "과(와) " + str2 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str2 + "은(는) 같지 않다.");			
		}
		
		if(str1.equals(str3)) {			//equals() : true, false 반환
			System.out.println(str1 + "과(와) " + str3 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str3 + "은(는) 같지 않다.");			
		}
		
		if(str1.equals(str4)) {			//equals() : true, false 반환
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같지 않다.");			
		}
		
		if(str1.equals(str4.toUpperCase())) {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같지 않다.");			
		}
		
		if(str1.toLowerCase().equals(str4)) {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같지 않다.");			
		}
		
		if(str1.equalsIgnoreCase(str4)) {	//대소문자 구분없이 비교한다.
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같다.");
		}else {
			System.out.println(str1 + "과(와) " + str4 + "은(는) 같지 않다.");			
		}
	}//main()
}//class








​
import java.util.Arrays;

public class Ex_String01 {
	//String Class : 문자열을 조작하기 위한 기능을 담고 있는 클래스
	//SunMicroSystem(Oracle) 업체에서 미리서 제작하여 제공 ▶ API(Library)
	//API 문서(설명서) : www.oracle.com > Java APIs
	//JRE System Library > rt.jar > java.lang > String.class
	public static void main(String[] args) {
		String str1 = "apple";	//apple 문자열을 str1 변수에 할당
		String str2 = new String("APPLE");	//APPLE 문자열을 str2 객체에 할당
		
		System.out.println(str1);
		System.out.println(str2);
		
		//문자열의 길이 : length()
		System.out.println("str1의 길이 : " + str1.length());
		
		//대문자로 변경 : toUpperCase()
		System.out.println("str1을 대문자로 변경 : " + str1.toUpperCase());
		
		//소문자로 변경 : toLowerCase()
		System.out.println("str2을 소문자로 변경 : " + str2.toLowerCase());
		
		//특정문자만 추출 : subString()
		System.out.println(str1.substring(1));		//index 1부터 끝까지 추출
		System.out.println(str1.substring(1, 3));	//index 1부터 3의 앞까지 추출
		
		//문자열에서 특정 문자 한 글자만 출력 : charAt()
		System.out.println(str2.charAt(3));
		System.out.println(str2.substring(3, 4));
		
		//특정 문자의 존재여부 : indexOf() ▶ 존재 : index 값을 반환, 실패 : -1
		int index = str2.indexOf("B");
		System.out.println(index);
		
		//문자열 분리 : split()
		String str3 = "가나@다라@마바";
		String[] sp = str3.split("@");
		for (int i = 0; i < sp.length; i++) {
			System.out.println(sp[i]);
		}
		System.out.println(Arrays.toString(sp));
		
		//문자열 치환(찾아 바꾸기) : replaceAll()
		System.out.println(str2.replaceAll("PP", "@@"));	//PP → @@
		System.out.println(str2.replaceAll("P", "@@"));		//P → @@
		
		//좌우 공백 제거 : trim()
		String str4 = "   abc   def   ";
		System.out.println(str4);
		System.out.println("공백 제거 전 길이 : " + str4.length());
		System.out.println(str4.trim());
		System.out.println("공백 제거 후 길이 : " + str4.trim().length());
	}//main()
}//class

 

'For developer > JAVA' 카테고리의 다른 글

자바 시간차이 문자열 변환  (0) 2021.03.31
JDBC 한눈에 보기  (0) 2020.04.26
JDBC 작업순서  (0) 2020.04.24
JDBC ORACLE 연결 오류 뜰 시 설정하는 법  (0) 2020.04.23
자바 환경구축  (0) 2020.04.23

JAVA EE 개발자 환경 구축

 

JAVA SE 개발환경이 구축 되어 있어야 한다(JDK가 설치되어 있어야 함).

 

Oracle DataBase 개발환경이 구축 되어 있어야 한다.

 

웹서버를 구축해야 한다. Tomcat Web Server

 

Tomcat Web Server 설치(등록)

- 검색창에서 tomcat 입력

- Apache Tomcat : http://tomcat.apache.org

- Download > Tomcat 8(https://tomcat.apache.org/download-80.cgi) > 8.5.54

- Binary Distributions > Core > 64-bit Windows zip : Download

- 압축해제 : apache-tomcat-8.5.54 폴더 복사

- C:\ 붙여넣기 C:\tomcat 폴더 이름 변경

- 시스템 변수 설정

 

 

Port 번호 변경(Oracle DB PortTomcat Port가 충돌)

- CMD Windows(Command) > sqlplus : User Name, Pass Word

- SQL>exec dbms_xdb.sethttpport(8888);

 

EclipseTomcat Server 연동

- D:\Study_Web\workspace 폴더 생성

- Eclipse 실행 > Launcher > Browse... > D:\Study_Web\workspace 변경 또는

File Menu Bar > Switch Workspace > Other > Browse > D:\Study_Web\workspace

- JAVE EE 변경 : Windows Menu Bar > Open Perspective > Others... > JAVA EE

- Windows Menu Bar > Show View > Servers > New Server...

- Apache > Tomcat v8.5 Server > Next

- Tomcat installation directory > Browse > C:\tomcat > Next > Finish

 

- C:\tomcat\lib\servlet-api.jarC:\Program Files\Java\jre1.8.0_241\lib\ext 붙여넣기

 

EclipseDatabase 연동

- Windows Menu Bar > Show View > Data Source Explorer

- Database Connections > 마오 > New

- Connection Profile > Oracle > Next > New Driver Definition

 

- JAR List > Add JAR/Zip... > C:\ oraclexe\ app\ oracle\ product\ 11.2.0\ server\ jdbc\ lib\ ojdbc6.jar

 

 

 

Dynamic Web Project 생성

- Eclipse File Menu Bar > New > Dynamic Web Project

 

 

Build Path 설정

- 프로젝트 명 > 마오 > Build Path > Configure Build Path...

- Default output folder 변경 :

Source > Browse...

- WebContent\WEB-INF\classes

 

Dynamic Web ProjectTomcat Server 연동

- Windows Menu Bar > Show View > Servers > Tomcat 8.5 >

마오 > Add and Remove > Project Add(Remove) > Finish

- Project Explorer Window > Servers > server.xml > Line Number 156

<Context docBase="01.FirstProject" path="/fp" ~~~/>

Context root 명이 중복될 경우 server.xmlpath값을 변경하면 된다. 변경한 후에 반드시 서버를 Restart 할 것.

Project Name > 마오 > Properties > Web Project Settings > Context root 변경하고, 서버를 Restart 할 것.

 

Web Programing(Java Resources > src), Web Page(WebContent) 제작

- 해당 폴더에서 마오 > New > Servlet, Class, package, html, css, javascript, JSP

- Eclipse 실행 : Run Menu Bar > Run As > Run on Server(Ctrl + F11)

- Web Browser 실행 : http://ServerIP주소:Port번호/Context root/Pagename.확장자

 

Encoding 변경

- Window MenuBar > Preferences > General

> Workspace > Text File encoding : UTF-8

- Window MenuBar > Preferences > Web > CSS, HTML, JSP : UTF-8

01.JAVA EE 개발환경 구축_2.hwp
0.58MB

'For developer > Servlet&JSP' 카테고리의 다른 글

(Servlet)requestDispatcher  (0) 2020.05.12
(Web.xml)Mapping 수동설정 하는 법  (0) 2020.05.12

+ Recent posts