Simplest HTTP-JSP-Servlet-Struts-JDBC-Hibernate demo

Java Web

x86 Assembly = Servlet
C  = JSP
C++  = JSF

================================
Online Shopping Cart
HTTP Cookies vs. HTTP QueryString/Web beacon
================================
HTTP Query String
Technically, the form content is only encoded as a query string when the form submission method is GET. The same encoding is used by default when the submission method is POST, but the result is not sent as a query string, that is, is not added to the action URL of the form. Rather, the string is sent as the body of the request.
================================

JDBC
1)JDBC-ODBC bridge
no additional thrid party jar requred, you can talk to Microsoft Access (*.mdb) in this way

2)thrid party JDBC driver
for instance, SQL Server Driver.
A note to know, when you execute the java class, go like this:
java -classpath .;msbase.jar;mssqlserver.jar;msutil.jar YourClass
=======================================================================
Servlet

* stand-alone servlet
1)create java file for instance %CATALINA_HOME%/webapps/myservlet/classes/SingleServlet.java and compile
2)add following line in %CATALINA_HOME%/webapps/myservlet/WEB-INF/web.xml
  <servlet>
    <servlet-name>SingleServlet</servlet-name>
    <servlet-class>SingleServlet</servlet-class>
  </servlet>
  <servlet>

  <servlet-mapping>
    <servlet-name>SingleServlet</servlet-name>
    <url-pattern>/SingleServlet</url-pattern>
  </servlet-mapping>
3)visit your work through
http://127.0.0.1:8080/myservlet/SingleServlet

* packaged servlets
1)create java file for instance %CATALINA_HOME%/webapps/myservlet/classes/mypkg/PkgServlet.java and compile
2)add following line in %CATALINA_HOME%/webapps/myservlet/WEB-INF/web.xml
  <servlet>
    <servlet-name>PkgServlet</servlet-name>
    <servlet-class>mypkg.PkgServlet</servlet-class>
  </servlet>
  <servlet>

  <servlet-mapping>
    <servlet-name>PkgServlet</servlet-name>
    <url-pattern>/PkgServlet</url-pattern>
  </servlet-mapping>
3)visit your work through
http://127.0.0.1:8080/myservlet/PkgServlet
=======================================================================
JSP(Tomcat)
download and install the windows msi package is ok.
to create you own web program

1)create folder under this one, %CATALINA_HOME%/webapps, for example, a folder named "hello"
%CATALINA_HOME%/Tomcat 5.5/webapps/hello
2)create a folder named WEB-INF under hello
<Path>/Tomcat 5.5/webapps/hello/WEB-INF
3)create index.jsp and place it into %CATALINA_HOME%/webapps/hello
4)visit you jsp file through http://127.0.0.1:8080/hello/index.jsp
*
5)to use JSTL
place jstl.jar and standard.jar into %CATALINA_HOME%/webapps/hello/WEB-INF/lib
=======================================================================
Hibernate
the fastest quickstart is to goole it with "hibernate tutorial", and go to road2hibernate
download the sample code and run it(the sample use hsqldb, an in-memory database)!! that is all!!

1)modify the sample to adapt to SQL Server
just modify the /src/hibernate.cfg.xml, change those lines:

        <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
        <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://127.0.0.1:1433;databasename=pubs</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password"></property>
        <property name="dialect">org.hibernate.dialect.SQLServerDialect</property>


and re-build and run it, that is all! (you even need not to create table, hbn will do this for you)
=======================================================================
Struts

to experience the framework, download the package and unpack it, then copy
apps/*.war to %CATALINA_HOME%/webapps/.
visit http://127.0.0.1:8080/struts2-blank-2.0.1
that is all! 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值