[ iT ] Forums: Thiết kế web bằng ngôn ngữ Java(Jsp) - [ iT ] Forums

Jump to content


Balloon vs. Thorns

MU Phuc Hung

Làm Việc Tài Nhà

Mu Da Nang

Tuyển Nhân Viên Bán Hàng

MU Moi ra - MU Vinh

Trang 1 / 1
  • Bạn không thể gửi chủ đề mới
  • Bạn không thể gửi trả lời cho chủ đề này

Thiết kế web bằng ngôn ngữ Java(Jsp) Java + Html Đánh Giá: -----

#1 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

  Gửi vào 08 January 2008 - 01:40 PM

Topic này là nơi tập trung về các ví dụ của Java trong web viết bằng ngôn ngữ JSP từ đơn giản đến phức tạp dần (Java Server Pages)

Để có thể học về JSP ngoài bộ JDK bạn cần có thêm bô JRUN 4.0 ... bạn có thể down ở đây

DownLoad
<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#2 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 08 January 2008 - 01:43 PM

Quote

thay thế một chuỗi con nào đó trong chuỗi mẹ thành chuỗi con khác


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

String str1="Select * from tblemplyurs";
str1= replaceString (str1,"u","o");
str1= replaceString (str1,"’","’’");
out.println("Char of Str1 is " + str1);
%>

<%!
public String replaceString(String sStr,String oldStr,String newStr)
{
sStr=(sStr==null?"":sStr);
String strVar=sStr;
String tmpStr="";
String finalStr="";
int stpos=0,endpos=0,strLen=0;
while (true)
{
strLen=strVar.length();
stpos=0;
endpos=strVar.indexOf(oldStr,stpos);
if (endpos==-1)
break;
tmpStr=strVar.substring(stpos,endpos);
tmpStr=tmpStr.concat(newStr);
strVar=strVar.substring(endpos+oldStr.length()>sStr.length()?endpos:endpos+oldStr.length(),strLen);
finalStr=finalStr.concat(tmpStr);
stpos=endpos;
}
finalStr=finalStr.concat(strVar);
return finalStr;
}
%>
</BODY>
</HTML>


Kết quả :

Quote

Char of Str1 is Select * from tblemplyors

Bài viết này được chỉnh sửa bởi PhươngĐiệp2410: 08 January 2008 - 01:44 PM

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#3 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 08 January 2008 - 11:39 PM

Quote

Tìm vị trí kí tự trong chuỗi

<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

String str1="Select * from tblemplyurs";
int vitri=str1.indexOf("o");
out.println("Location of o is " + vitri);
%>
</BODY>
</HTML>


Kết quả

Quote

Location of o is 11

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#4 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 08 January 2008 - 11:42 PM

Quote

Chuyển đổi chữ hoa sang chữ thường hay ngược lại


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

String str1="Select * from tblemplyors";
str1=str1.toLowerCase();
out.println("LowerCase is " + str1);
str1=str1.toUpperCase();
out.println("UpperCase is " + str1);
%>
</BODY>
</HTML>


Kết quả

Quote

LowerCase is select * from tblemplyors UpperCase is SELECT * FROM TBLEMPLYORS

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#5 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 08 January 2008 - 11:52 PM

Quote

Khác nhau giữa hai phép toán i++ và ++i


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

int i=0,j=0;
j=i++;
out.println("Value of j is " + j);
j=++i;
out.println("Value of j is " + j);
%>
</BODY>
</HTML>


Kết quả

Quote

Value of j is 0 Value of j is 2

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#6 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 08 January 2008 - 11:56 PM

Quote

Toán tử not (~ !)


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

short i=32767;
boolean b=true;
out.println("Value of ~ short is " + ~i);
out.println("Value of !b is " +!b);
%>
</BODY>
</HTML>


Kết quả

Quote

Value of ~ short is -32768 Value of !b is false

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#7 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 09 January 2008 - 12:24 AM

Quote

Các phép toán + _ * /


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

int i=767;
int j=10;
out.println("Value of multi is " + i*j);
out.println("Value of divide is " +i/5);
out.println("Value of add is " +i+5);
out.println("Value of subtract is "+(i-5));
%>
</BODY>
</HTML>


Kết quả

Quote

Value of multi is 7670 Value of divide is 153 Value of add is 7675 Value of subtract is 762

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#8 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 09 January 2008 - 12:29 AM

Quote

Khi muốn lấy số dư của phép chia thì bạn dùng phép toán modulus(%)


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%

int i=10;
int j=3;
out.println("Value of i%j is " + i%j);
%>
</BODY>
</HTML>


Quote

Value of i%j is 1

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#9 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 09 January 2008 - 06:07 AM

Quote

Phép toán &&(và) ||(Hoặc)


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%
boolean b=true;
int j=3;
if((j>=3) &&(b!=true))
out.println("result is true");
if((j<3) ||(b==true))
out.println("result is false");

%>
</BODY>
</HTML>


Kết quả


Quote

result is false

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#10 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 09 January 2008 - 06:21 AM

Quote

Phép toán >,>=,<,<=,==,!=


<HTML>
<HEAD>
<title>Test JSP</title>
</HEAD>
<BODY>
<%
int i=10;
int j=3;
if(i>=j)
out.println("result is true");
else
out.println("result is false");
if(i!=j)
out.println("result is not equals");
else
out.println("result is equals");

%>
</BODY>
</HTML>


Kết quả

Quote

result is true result is not equals

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

#11 User is offline   PhươngĐiệp2410 

  • Nhóm: VIP
  • Bài Viết: 1917
  • Gia Nhập: 08-March 07
  • Thạc sĩ CSTH
  • PipPipPipPipPip

Gửi vào 09 January 2008 - 06:43 AM

Quote

Tạo giao diện như trong hình (sẽ chèn mã Java sau ... bạn có thể dùng Dreamweaver thì nhanh hơn gõ nhiều hoặc nhanh hơn nữa thì copy và paster)
Posted Image


<%@ page contentType="text/html; charset=UTF-8" %>
<html>
<head>
<title>JSP's Objects</title>
<LINK href="style.css" rel=stylesheet>
<LINK href="newstyle.css" rel=stylesheet>
<META HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=utf-8">
</head>
<body leftmargin="0" topmargin="0" >
<tr><td></td><td>Registration</td></tr>
<form name=form1 action=ex2.jsp method=post>
<table border=0>
<tr>
<td>Name: </td><td><input type=text name=txtname></td></tr>
<tr><td>Province: </td><td><select name=province>
<option value=HAN> Ha Noi </option>
<option value=HUE> Hue </option>
<option value=HCM> Ho Chi Minh </option>
</select></td></tr>
<tr><td>Description: </td><td>
<textarea name=txtdesc cols=30 rows=5></textarea></td>
</tr>
<tr><td></td><td><input type=submit value="Submit"></td></tr>
</table>
</form>
</body>
</html>

<div align='center'><!--coloro:#008080--><span style="color:#008080"><!--/coloro--><i><b><!--sizeo:5--><span style="font-size:18pt;line-height:100%"><!--/sizeo--><a href="http://winsocks.net/" target="_blank">http://winsocks.net/</a>

<!--sizec--></span><!--/sizec--></b></i><!--colorc--></span><!--/colorc--><!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b>Are You looking for a good socks 5 service? But you don't know where to buy?
Welcome to WinSocks.Net - Crazy Socks Service
Here we provide Fresh Socks 5 with fast speed , less blacklist, especially price is cheaper than others service.</b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec--> <!--sizeo:3--><span style="font-size:12pt;line-height:100%"><!--/sizeo--><!--coloro:#0000ff--><span style="color:#0000ff"><!--/coloro--><b><i>More over, if you want to test our socks 5 before buying, don't be hesitate to contact our supporter through yahoo to receive Free Socks 5</i></b><!--colorc--></span><!--/colorc--><!--sizec--></span><!--/sizec-->
</div>
0

Chia sẻ chủ để


Trang 1 / 1
  • Bạn không thể gửi chủ đề mới
  • Bạn không thể gửi trả lời cho chủ đề này

1 người đang đọc chủ đề này
0 thành viên, 1 khách, 0 thành viên ẩn