c:\Server\Apache\bin>chcp
Текущая кодовая страница: 866
c:\Server\Apache\bin>chcp 1251
Текущая кодовая страница: 1251
SQL> select * from customers;
ID NAME
============ ==================================================
1 first
2 ўв®а®©
4 зҐвўҐавл©
5 пятый
AuthServer = Srp, Legacy_Auth
UserManager = Srp, Legacy_Auth
WireCrypt = Enabled
CREATE USER SYS PASSWORD 'пароль' USING PLUGIN Legacy_UserManager;
GRANT SELECT, UPDATE, INSERT, DELETE ON customers TO SYS;
<%
String input_parameter="Итого";
String Driver_Class="oracle.jdbc.driver.OracleDriver";
String Connection_URL="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=myoracle)))";
String UserName="user";
String Password="password";
Connection conn = null;
CallableStatement stmt = null;
ResultSet rset = null;
String SOME_NAME = "{call REPORTS.inwork(?,?)}";
// в SYS_REFCURSOR 4 поля для вывода - начало с 1.
try {
conn = DriverManager.getConnection(Connection_URL,UserName, Password);
stmt = conn.prepareCall(SOME_NAME);
stmt.setString(1, input_parameter);
stmt.registerOutParameter(2, OracleTypes.CURSOR);
stmt.execute();
rset = (ResultSet) stmt.getObject(2);
while (rset.next()) {
%>
<TR>
<TD><%=rset.getString(1)%></TD>
<TD><%=rset.getString(2)%></TD>
<TD><%=rset.getString(3)%></TD>
<TD><%=rset.getString(4)%></TD>
</TR>
<%
}
} catch (Exception e) {
out.println( "<h1>exception: "+e.getClass().getName() + ": " + e.getMessage()+"</h1>" );
} finally {
}
%>
</table>
Connection conn = null;
CallableStatement stmt = null;
ResultSet rset = null;
String SOME_NAME = "{call REPORTS.mi_inwork(?,?)}";
try {
conn = DriverManager.getConnection(Connection_URL,UserName, Password);
stmt = conn.prepareCall(SOME_NAME);//We have declared this at the very top
stmt.setString(1, "Итого");//Passing CompanyID here
stmt.registerOutParameter(2, OracleTypes.CURSOR);//Refcursor selects the row based upon query results provided in Package.
stmt.execute();
rset = (ResultSet) stmt.getObject(2);
while (rset.next()) {
out.println(rset.getString(1)+" | "+ rset.getString(2)+" | "+ rset.getString(3));
}
} catch (Exception e) {
// LOGGER.error("Error extracting ", e);
out.println( "<h1>exception: "+e.getMessage()+"</h1>" );
} finally {
// DBUtils.cleanUp(conn, stmt, rset);
}
JSONParser parser = new JSONParser();
JSONObject obj;
try {
obj = (JSONObject) parser.parse(new FileReader("E:\\json.txt"));
out.println("<br>"+obj);
JSONObject jsonObject = (JSONObject) obj;
JSONArray from_excel = (JSONArray)jsonObject.get("from_excel");
// вариант построчного вывода 1
for(Object o: from_excel){
out.println("<br>"+o);
}
// вариант построчного вывода 2
Iterator iterator = from_excel.iterator();
while (iterator.hasNext()) {
out.println("<br>"+iterator.next());
}
// вариант поименного вывода 3
for (int i = 0; i < from_excel.size(); i++) {
JSONObject jsonObjectRow = (JSONObject) from_excel.get(i);
String num = (String) jsonObjectRow.get("num");
String solution = (String) jsonObjectRow.get("solution");
out.println("<br>num="+num+"; solution="+solution);
}
} catch (Exception e) {
out.println("Ошибка: "+e);
}
<SCRIPT language="javascript">
function GetValue () {
var result = [];
var vars_for_update="";
[].forEach.call(document.querySelector('form').elements, function (el) {
if (['checkbox', 'radio', 'button', 'submit'].indexOf(el.type) === -1 ) // || el.checked
{
//var elem = el.name;
var defValue = el.defaultValue;
var currvalue = el.value;
var index = el.selectedIndex;
if (index) defValue = el.options[0].value;
if (defValue == currvalue || index === 0) {
result.push(el.name + ' :: ' + el.value+' :: '+" Значение не изменилось");
} else {
result.push(el.name + ' :: ' + el.value+' :: '+" Значение изменилось с " + defValue +
"\n на " + currvalue);
vars_for_update=vars_for_update+el.name + '==' + el.value+"<>;";
}
}
});
demo.innerHTML = result.join('<br>');
if (vars_for_update!="") {
document.getElementById("Text_Update").value=vars_for_update;
}
}
</SCRIPT>
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("", Samba_User, Samba_Password);
// папка откуда забирать
String SambaURL = "smb://" + args[0];
// папка куда копировать
File destinationFolder = new File(args[1]);
File file = new File(args[2]);
System.out.println("Запущено с параметрами.");
System.out.println("Samba с файлами: " + SambaURL);
System.out.println("Локальная папка с файлами для обработки: " + destinationFolder);
System.out.println("Log работы в файл: " + file);
System.out.println("Чтение файлов в папке Samba: " + SambaURL);
// создаем папку если ее нет
if (!destinationFolder.exists()) {
destinationFolder.mkdirs();
}
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS_");
SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss dd.MM.yyyy");
Date date = new Date();
int StartTime = (int) new Date().getTime();
String StartDateTime = dateFormat.format(date);
SmbFile dir = new SmbFile(SambaURL, auth);
for (SmbFile f : dir.listFiles()) {
try {
child = new File(destinationFolder + "/" + f.getName());
fileToGet = new SmbFile(SambaURL + f.getName(), auth);
fileToGet.connect();
in = new BufferedInputStream(new SmbFileInputStream(fileToGet));
out = new BufferedOutputStream(new FileOutputStream(child));
byte[] buffer = new byte[4096];
int len = 0; //Read length
while ((len = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, len);
}
out.flush(); //The refresh buffer output stream
try {
printlnAppen(file, "[" + StartDateTime + "]: Скопирован файл - " + f.getName() + ".");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
} catch (Exception e) {
String msg = "The error occurred: " + e.getLocalizedMessage();
System.out.println(msg);
} finally {
try {
if (out != null) {
out.close();
}
if (in != null) {
in.close();
}
} catch (Exception e) {
}
}
<form method="POST" action="InsertInDB" name="InsertInDB">
элементы формы table, input и т.д.
<button class="btn btn-infoy" type="submit" onclick="GetDefValue()"><i class="glyphicon glyphicon-inbox"></i> Сохранить</button>
</form>
<script>
function GetDefValue () {
var elem = document.getElementById("email1");
var defValue = elem.defaultValue;
var currvalue = elem.value;
if (defValue == currvalue) {
document.getElementById("demo_3").innerHTML = "Знечение не изменилось";
} else {
document.getElementById("demo_3").innerHTML = "Значение изменилось с " + defValue +
"\n на " + currvalue;
}
}
</script>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<jsp-config>
<!-- JSTL Tag Library Local Descriptors -->
<taglib>
<taglib-uri>/WEB-INF/jstl/custom_tag_attribute.tld</taglib-uri>
<taglib-location>/WEB-INF/jstl/custom_tag_attribute.tld</taglib-location>
</taglib>
<taglib>
</web-app>
package com.yeepay.g3.app.cd.utils;
import com.jcraft.jsch.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
private String ipAddress;
private String username;
private String password;
public static final int DEFAULT_SSH_PORT = 22;
public Test(final String ipAddress, final String username, final String password) {
this.ipAddress = ipAddress;
this.username = username;
this.password = password;
}
public int execute(final String command) {
int returnCode = 0;
JSch jsch = new JSch();
try {
jsch.setKnownHosts("/Users/wtnull/.ssh/known_hosts");
// Create and connect session.
Session session = jsch.getSession(username, ipAddress, DEFAULT_SSH_PORT);
session.setPassword(password);
session.connect();
// Create and connect channel.
Channel channel = session.openChannel("exec");
((ChannelExec) channel).setCommand(command);
channel.setInputStream(null);
BufferedReader input = new BufferedReader(new InputStreamReader(channel.getInputStream()));
channel.connect();
System.out.println("The remote command is: " + command);
// Get the output of remote command.
String line;
while ((line = input.readLine()) != null) {
System.out.println(line);
}
input.close();
// Get the return code only after the channel is closed.
if (channel.isClosed()) {
returnCode = channel.getExitStatus();
}
// Disconnect the channel and session.
channel.disconnect();
session.disconnect();
} catch (JSchException | IOException e) {
e.printStackTrace();
}
return returnCode;
}
public static void main(final String [] args) throws Exception {
Test sshExecutor = new Test("172.17.102.180", "root", "123456");
sshExecutor.execute("free -m");
}
}
<script type="text/javascript">
var jsonObj = ${json_text};
var jsonResult = [];
jsonResult.push("Вывод JSON="+'<c:out value="${json_text}"/>');
jsonResult.push("количество строк json="+jsonObj.length);
result_json.innerHTML = jsonResult.join('<br>');
</script>
InputStream in = null;
OutputStream out = null;
try{
String SambaURL= "smb://usersamba:1234@192.168.1.110/data/1b.csv";
File destinationFolder = new File("C:\\Temp\\IN\\");
SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMddHHmmssSSS_");
File child = new File (destinationFolder+ "/" + fmt.format(new Date()) +"1b.csv");
SmbFile dir = new SmbFile(SambaURL);
SmbFile fileToGet=new SmbFile(SambaURL);
fileToGet.connect();
in = new BufferedInputStream(new SmbFileInputStream(fileToGet));
out = new BufferedOutputStream(new FileOutputStream(child));
byte[] buffer = new byte[4096];
int len = 0; //Read length
while ((len = in.read(buffer, 0, buffer.length)) != -1) {
out.write(buffer, 0, len);
}
out.flush(); //The refresh buffer output stream
}
catch (Exception e) {
String msg = "The error occurred: " + e.getLocalizedMessage();
System.out.println(msg);
}
finally {
try {
if(out != null) {
out.close();
}
if(in != null) {
in.close();
}
}
catch (Exception e) {}
}
#wrapper.java.mainclass=org.tanukisoftware.wrapper.demo.DemoApp
#wrapper.java.mainclass=COM.MainTaskRunner
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
#wrapper.java.classpath.1=../lib/wrapperdemo.jar
wrapper.java.classpath.1=C:/New/MainRunner.jar
wrapper.java.classpath.2=../lib/wrapper.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib
wrapper.java.library.path.2=C:/New/MainRunner/lib
# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE
# Java Additional Parameters
wrapper.java.additional.1=
# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3
# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64
# Application parameters. Add parameters as needed starting from 1
#wrapper.app.parameter.1="Oracle"
# The first application parameter is the name of the class whose main
# method is to be called when the application is launched. The class
# name is followed by the number of parameters to be passed to its main
# method. Then comes the actual parameters.
wrapper.app.parameter.1=COM.MainRunner
wrapper.app.parameter.2="Oracle"
# Java Main class. This class must implement the WrapperListener interface
# or guarantee that the WrapperManager class is initialized. Helper
# classes are provided to do this for you. See the Integration section
# of the documentation for details.
wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp
# Java Classpath (include wrapper.jar) Add class path elements as
# needed starting from 1
wrapper.java.classpath.1=../lib/example.jar
wrapper.java.classpath.2=../lib/wrapper.jar
# Java Library Path (location of Wrapper.DLL or libwrapper.so)
wrapper.java.library.path.1=../lib
wrapper.java.library.path.2=../lib/lib
# Java Bits. On applicable platforms, tells the JVM to run in 32 or 64-bit mode.
wrapper.java.additional.auto_bits=TRUE
# Java Additional Parameters
wrapper.java.additional.1="Oracle"
# Initial Java Heap Size (in MB)
#wrapper.java.initmemory=3
# Maximum Java Heap Size (in MB)
#wrapper.java.maxmemory=64
# Application parameters. Add parameters as needed starting from 1
wrapper.app.parameter.1=
@WebServlet(
name = "AuthenticationFilter",
description = "Аутентификационный фильтр",
urlPatterns = "/AuthenticationFilter"
)
@WebFilter("*.jsp")
public class AuthenticationFilter implements Filter {
private ServletContext context;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
this.context = filterConfig.getServletContext();
this.context.log("AuthenticationFilter initialized");
}
@Override
public void destroy() {
//close any resources here
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse res = (HttpServletResponse) response;
String uri = req.getRequestURI();
this.context.log("Requested Resource::" + uri);
HttpSession session = req.getSession(false);
Object user_o = req.getSession().getAttribute("username");
this.context.log("Фильтр аутентификации, пользователь::" + user_o);
if (user_o == null && !(uri.endsWith("index.jsp") || uri.endsWith("LoginUser"))) {
this.context.log("Неавторизованный запрос");
res.sendRedirect("index.jsp");
} else {
// pass the request along the filter chain
this.context.log("Авторизованный запрос, сессия:: " + session);
chain.doFilter(request, response);
}
}
}