Biblioteca Java

Subversion Repositories:
Compare Path: Rev
With Path: Rev
/Courses and labs samples/ @ 18  →  /Courses and labs samples/ @ 19
New file
/Courses and labs samples/SCD/Servlet/WebApp/.classpath
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="D:/temp/apache-tomcat-7.0.57/lib/servlet-api.jar"/>
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/mysql-connector-java-5.1.25-bin.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
New file
/Courses and labs samples/SCD/Servlet/WebApp/.project
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>WebApp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
New file
/Courses and labs samples/SCD/Servlet/WebApp/src/exemple/scd/web/AdaugaPersoanaServlet.java
@@ -0,0 +1,33 @@
package exemple.scd.web;
 
import java.io.IOException;
import java.io.PrintWriter;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
* Servlet implementation class AdaugaPersoanaServlet
*/
@WebServlet(name = "adaugaPersoana", urlPatterns = { "/adaugaPersoana" })
public class AdaugaPersoanaServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String nume = request.getParameter("nume");
String prenume = request.getParameter("prenume");
PrintWriter out = response.getWriter();
out.println("Hello "+nume+" "+prenume);
out.close();
}
 
}
New file
/Courses and labs samples/SCD/Servlet/WebApp/src/exemple/scd/web/HelloWorldServlet.java
@@ -0,0 +1,53 @@
package exemple.scd.web;
 
import java.io.IOException;
import java.io.PrintWriter;
 
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
* Servlet implementation class HelloWorldServlet
*/
@WebServlet(name = "hello", urlPatterns = { "/hello" })
public class HelloWorldServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
int counter = 0;
/**
* @see HttpServlet#HttpServlet()
*/
public HelloWorldServlet() {
super();
// TODO Auto-generated constructor stub
}
 
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
counter++;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("<h3>You are visitor number:"+counter+"</h3>");
out.println("</body>");
out.println("</html>");
}
 
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
 
}
New file
/Courses and labs samples/SCD/Servlet/WebApp/src/exemple/scd/web/AdaugaPersoana2Servelet.java
@@ -0,0 +1,53 @@
package exemple.scd.web;
 
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
 
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
 
/**
* Servlet implementation class AdaugaPersoana2Servelet
*/
@WebServlet(name = "adaugaPersoana2", urlPatterns = { "/adaugaPersoana2" })
public class AdaugaPersoana2Servelet extends HttpServlet {
private static final long serialVersionUID = 1L;
private Connection con;
/**
* @see Servlet#init(ServletConfig)
*/
public void init(ServletConfig config) throws ServletException {
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/webapp?user=root");
}catch(Exception e){
e.printStackTrace();
}
}
 
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String nume = request.getParameter("nume");
String prenume = request.getParameter("prenume");
PrintWriter out = response.getWriter();
try{
Statement s = con.createStatement();
s.executeUpdate("INSERT INTO PERSOANE VALUES('"+nume+"','"+prenume+"')");
out.println("Inregistrarea a fost adaugata");
}catch(SQLException e){
out.println("A aparut o eroare pe server la introducere date:"+e.getMessage());
}
}
 
}
New file
/Courses and labs samples/SCD/Servlet/WebApp/WebContent/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path:
 
New file
/Courses and labs samples/SCD/Servlet/WebApp/WebContent/WEB-INF/web.xml
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>WebApp</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
</web-app>
New file
/Courses and labs samples/SCD/Servlet/WebApp/WebContent/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Aplicatie de test</title>
</head>
<body>
Aceasta este prima pagina din proiectul de test.
</body>
</html>
New file
/Courses and labs samples/SCD/Servlet/WebApp/WebContent/adaugaPersoana.html
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Adauga persoana</title>
</head>
<body>
<h3>Adaugare persoana</h3>
<form action="adaugaPersoana2" method=POST>
Nume:
<input type=text size=20 name=nume>
<br>
Prenume:
<input type=text size=20 name=prenume>
<br>
<input type=submit value="Trimite">
</form>
 
 
</body>
</html>
New file
/Courses and labs samples/SCD/Servlet/WebApp/readme.txt
@@ -0,0 +1,5 @@
Exemplu simplu aplicatie web cu servleturi.
Contine:
- servlet HelloWorldServlet
- servlet AdaugaPersoanaServlet exemplu procesare form (citire parametri din form)
- servlet AdaugaPersoanaServlet2 exemplu conectare si scriere date intr-o baza de date
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/org.eclipse.wst.jsdt.ui.superType.name
@@ -0,0 +1 @@
Window
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/org.eclipse.wst.jsdt.ui.superType.container
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/org.eclipse.wst.common.project.facet.core.xml
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<fixed facet="java"/>
<fixed facet="jst.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/.jsdtscope
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
New file
/Courses and labs samples/SCD/Servlet/WebApp/.settings/org.eclipse.wst.common.component
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="WebApp">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="WebApp"/>
<property name="java-output-path" value="/WebApp/build/classes"/>
</wb-module>
</project-modules>