Deutsch
Germany.ruФорумы → Архив Досок→ Программирование

Вопросик из области Web-Programmierung, Java

08.09.15 17:03
Re: Вопросик из области Web-Programmierung, Java
 
v0id* патриот
v0id*
В ответ на:
Только это не говорит о том что у вас на томкате сессия по ип выдается.

Я у шефа спрашивал, он сказал, что 100% по IP
Да и как еще, если всегда одна сессия на рыло?
В ответ на:
Вангую: у апплета есть метод который вызывает sendRequest(- -) и передает кму как параметр объект типа AuthenticationData. Это и есть метод для логина.

Ванговать не надо, sendRequest(- -) у меня выше описан Как и про пароль с логином.
Вызывается он с объектом типа ServletTransfer- -.
В ответ на:
Я имел в виду томкат, где ваш deployment de- -or для вашего сервлета. Ищите context.xml

Есть, но он практически пустой:
less server.xml
<Server port="18160" shutdown="SHUTDOWN" debug="0">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true"
crossContext="false"
debug="0"
displayName="ICM-6 Entwicklung"
docBase="/home/icm6/dcc/web/lib"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/ICM6"
privileged="true"
reloadable="true"
swallowOutput="false"
useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Resources className="org.apache.naming.resources.FileDirContext"
allowLinking="true" />
</Context>
</Host>
</Engine>
</Service>
</Server>
В ответ на:
setGeneralParameters тоже похож на код апплета. На мои вопросы не отвечает.

Код public class ndServlet extends HttpServlet ниже, а здесь сначала еще один класс, который этим занимается:
public class GeneralServerAdapter_Servlet extends GeneralServerAdapter
implements IGeneralServerAdapter
{
private URL m_servlet = null;

..........
/**
* Special method to return the result data of the request.
*
* This is handled in a separate method to support advanced communication
* issues like e.g. multi block data transfer.
*/
protected - - getResultData(ServletTransfer- - reqObj,
ServletTransfer- - resObj) throws GeneralException
{
- - obj = resObj.getData- -();
// if there is a special communication - - returned
// -> this is a multi block data transfer
if (obj == null)
return (obj);
if (!(obj instanceof ndCommunication- -))
return (obj);
// special communication required - multi block data transfer
ndCommunication- - ndComm = (ndCommunication- -)obj;
// The result we receive can take two different forms:
// - a normal vector, which contains data elements and we
// have to append following data blocks to this vector
// - a special vector containing exactly two elements
// -> a de- -ion - -
// -> a data vector (where we have to append the following data)
- - objResult = ndComm.getData();
Assertion.verify(objResult instanceof Vector<?>);
Vector<?> vecResult = (Vector<?>) objResult;
// locate the relevant data vector to which we will add the following
// data blocks
@SuppressWarnings("unchecked")
Vector<- -> vecReceivedData = (Vector<- ->) vecResult;
// if the result vector as two elements and the second element is a vector
// the "real" result is the second element
if ((vecResult.size() == 2) && (vecResult.elementAt(1) instanceof Vector<?>))
{
@SuppressWarnings("unchecked")
Vector<- -> realResultVec = (Vector<- ->) vecResult.elementAt(1);
vecReceivedData = realResultVec;
}
// NOTE: if we now add data to vecReceivedData, we add it indirectly either
// to vecResult (in case vecResult is the "real" data vector) or to
// the second element of vecResult (in case the second element is the
// "real" data vector)
// prepare the special transfer - - to communicate with the servlet
reqObj.setAdapterMethod("getNextDataBlock");
reqObj.setArgumentClass(ndComm.getClass().getName());
while (ndComm.isMoreDataAvailable())
{
// read the next data block
reqObj.setData- -(ndComm);
ndComm.setDataCompressed(false);
ndComm.setData(null);
resObj = (ServletTransfer- -)doRequest(reqObj);
if (resObj.getException() != null)
throw resObj.getException();
obj = resObj.getData- -();
// append data of the current block to the result vector
Assertion.verify(obj instanceof ndCommunication- -);
ndComm = (ndCommunication- -)obj;
Vector<?> vecNewData = (Vector<?>) ndComm.getData();
VectorSupport.addAllFrom(vecNewData, vecReceivedData);
}
return vecResult;
}
public synchronized - - doRequest(ServletTransfer- - obj)
throws GeneralException
{
// the method is synchronized for this - - which means there can only
// be one request via this - - at a time
// -> but to be sure that there is only one request at a time from
// -> the virtual machine (from the Client) we synchronize
// -> via a static - -
- - objResult = null;
synchronized(c_fSyncSendRequest)
{
try
{
getServlet();
// Send the request
// sometimes there occurs an IOException in IE context so we'll
// try it several times
int iTries = 1;
boolean fOk = false;
InputStream in = null;
while (!fOk)
{
try
{
iTries++;
in = sendRequest(obj);
fOk = true;
}
catch (IOException ex)
{
// we allow three tries...
if (iTries >= 3)
throw ex;
Trace.traceInfo("IOException occurred - try again...");
}
}
// now get the result
- -InputStream result = new - -InputStream(in);
// and build the result - -
objResult = result.read- -();
in.close();
m_connection = null;
}
catch (Throwable e)
{
...
}
}
return (objResult);
}
public URL getServlet() throws GeneralException
{
// if it is already there - use it - but only if security hasn't changed...
if (m_servlet != null && m_iLastSecurityLevel == getCurrentServletSecurityLevel())
{
return (m_servlet);
}
// try to get the servlet
try
{
showInfo("Servlet-Name: " + getServletName());
m_servlet = new URL(getServletName());
m_iLastSecurityLevel=getCurrentServletSecurityLevel();
}
catch (Throwable e)
{
m_servlet = null;
throw new GeneralException(e);
}
return (m_servlet);
}
public synchronized InputStream sendRequest(Serializable obj) throws Throwable
{
showInfo("Open connection to servlet: " + m_servlet.toString());
m_connection = m_servlet.openConnection();
// Prepare for both input and output
m_connection.setDoInput(true);
m_connection.setDoOutput(true);
// Turn off caching
m_connection.setUseCaches(false);
// Set the content type to be java-internal/classname
m_connection.setRequestProperty("Content-Type",
"java-internal/" + obj.getClass().getName());
// Write the serialized - - as post data
- -OutputStream out = new - -OutputStream(m_connection.getOutputStream());
out.write- -(obj);
out.flush();
out.close();
return m_connection.getInputStream();
}
В ответ на:
Вы знаете, вы похоже думаете, что вы накидаете куски кода а вам - раз и выложат решение.

Нет, я так не думаю. Вы меня просили показать код, я показал. Ну, ошибся разок, извините.
В ответ на:
Прошла неделя

Еще не прошла. Я только в пятницу открыл ветку
Учтите, что я в этом деле профан и иду, как по минному полю.
В ответ на:
Подсказать направление я вам могу, а за вас делать меньше сотни за час не возьму.

Направление мне и надо.
В ответ на:
Две подсказки:
- у вас нет никакой HttpSession на томкате.

Да, видимо, это верно. Я покопался в логах томката, никакой HttpSession там не нашел. В коде она есть, в том самом пакете Servlet и классе ndServlet extends HttpServlet:
* The ndServlet class provides transport functionality from the client
* side to the RMI-server.

*
* @version 1.00 03.12.1999
* @see HttpServlet
*/
public class ndServlet
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
HttpSession session = request.getSession(true);
showInfo("session got: " + session.getId());
if (session.getAttribute(KEY_BINDING_LISTENER) != this)
session.setAttribute(KEY_BINDING_LISTENER, this);
else
showInfo("ndServlet.doPost, getAttribute(KEY_BINDING_LISTENER) <> this");
public void init(ServletConfig config) throws ServletException
{
super.init(config);
String hostname;
String maxBlockSize;
int tracelevel;
//In the Moment, we set no Security! It remains to check, if you can do it with policy-files
//System.setSecurityManager(new NoSecurityManager());
// Trace on/off?
if (config.getInitParameter("Trace") != null)
{
tracelevel = Integer.parseInt(config.getInitParameter("Trace"));
if ((tracelevel > Trace.TRACE_OFF) &&
(tracelevel <= Trace.FUNCTION_TRACE))
Trace.setTraceLevel(tracelevel);
}
showInfo("ndServlet.init: init called ...");
// set the server for the RMI-Communication
if ((hostname = config.getInitParameter("HostName")) != null)
{
GeneralServerAdapter.setHostName(hostname);
showInfo("hostname for RMI set to: " + hostname);
}
// enable own support for communication
if (config.getInitParameter("HandleCommunication") != null)
{
String str = config.getInitParameter("HandleCommunication");
boolean fEnable = (Integer.parseInt(str) != 0);
c_fSpecialCommunicationSupport = fEnable;
if (fEnable)
showInfo("Special support for communication enabled");
}
// handle special parameters for special communication (if this is enabled)
if (c_fSpecialCommunicationSupport)
{
// set the max transfer block size
if ((maxBlockSize = config.getInitParameter("TransferBlockSize")) != null)
{
setMaxTransferBlockSize(Integer.parseInt(maxBlockSize));
}
showInfo("Transfer block size: " + c_iMaxBlockSize);
// enable compression for data transfer if requested
if (config.getInitParameter("TransferCompression") != null)
{
String str = config.getInitParameter("TransferCompression");
boolean fEnable = (Integer.parseInt(str) != 0);
setUseCompressionForTransfer(fEnable);
if (fEnable)
showInfo("Compression activated for transfer");
else
showInfo("Compression deactivated for transfer");
}
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
showInfo("doGet called...");
}
public void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
super.service(req, resp);
}
//Process the HTTP Post request
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
try
{
AnalyzeSupport timeSup = new AnalyzeSupport();
showInfo("doPost started");
// first get the request - -
- -InputStream objIn = new - -InputStream(request.getInputStream());
ServletTransfer- - objTransfer = (ServletTransfer- -)objIn.read- -();
objIn.close();
- - objResult;
// now handle special case: multi block transfer
// (in case of own support for communication)
if (!(objTransfer.getData- -() instanceof ndCommunication- -) ||
!c_fSpecialCommunicationSupport)
{
// now fulfill the request which is described in the transfer - -
// -> first build the requested instance
Class<?> clsAdapter = Class.forName(objTransfer.getAdapterClass());
- - objAdapter = clsAdapter.newInstance();
// -> and then call the method to get the result
Class<?> paramClasses[] = null;
- - params[] = null;
if (objTransfer.getData- -() != null)
{
paramClasses = new Class[1];
paramClasses[0] = Class.forName(objTransfer.getArgumentClass());
params = new - -[1];
params[0] = objTransfer.getData- -();
}
Method met = clsAdapter.getMethod(objTransfer.getAdapterMethod(), paramClasses);
// set binding listener for session if it's not already done...
HttpSession session = request.getSession(true);
showInfo("session got: " + session.getId());
if (session.getAttribute(KEY_BINDING_LISTENER) != this)
session.setAttribute(KEY_BINDING_LISTENER, this);
else
showInfo("ndServlet.doPost, getAttribute(KEY_BINDING_LISTENER) <> this");
// save the Prefix to be used for server communication from this servlet
setServerNamePrefix(objTransfer.getServerNamePrefix());
if (objAdapter instanceof GeneralServerAdapter)
{
GeneralServerAdapter adapt = (GeneralServerAdapter)objAdapter;
adapt.setServerNamePrefix(this.getServerNamePrefix());
}
// set current sessionid in Adapter as the access key
if (objAdapter instanceof GeneralServerAdapter_RMI)
{
GeneralServerAdapter_RMI adapt = (GeneralServerAdapter_RMI)objAdapter;
adapt.setAccessKey(session.getId());
showInfo("ndServlet.doPost, SessionID(access key) set: " + session.getId());
// also use the session id as request id
adapt.setRequestId(session.getId());
// the adapter should handle special communication issues
// in case the servlet should also do it on its own
adapt.setHandleSpecialCommunication(c_fSpecialCommunicationSupport);
}
AnalyzeSupport timeSup2 = new AnalyzeSupport();
showInfo("ndServlet.doPost, Method: " + met.getName());
objResult = met.invoke(objAdapter, params);
timeSup2.showTimeUsage("ndServlet.doPost RMI-Invocation-Time:");
}
else
{
// special communication
showInfo("getNextDataBlock...");
objResult = this.getNextDataBlock((ndCommunication- -)objTransfer.getData- -());
}
if (objResult != null)
{
// now build the response - -
objTransfer.setData- -((Serializable)this.getResult- -(objResult));
// ...and send it back to the requestor
response.setContentType("java-internal/" + objResult.getClass().getName());
}
else
{
objTransfer.setData- - (null);
response.setContentType("java-internal/null");
}
// now write the - - to the response output stream
this.write- -(response, objTransfer);
timeSup.showTimeUsage("PP_Servlet Request-Time:");
}
catch (Throwable e)
{
GeneralException ex;
if (e instanceof GeneralException)
ex = (GeneralException)e;
else
ex = new GeneralException(e);
// ...and send it back to the requestor
response.setContentType("text/html");
ServletTransfer- - objTransfer = new ServletTransfer- -();
objTransfer.setData- -(new Vector<- ->());
objTransfer.setException(ex);
// now write the - - to the response output stream
this.write- -(response, objTransfer);
}
}
/**
* Special handling for returning the result - -
* created for the current request.
*/
protected - - getResult- -(- - result) throws GeneralException
{
boolean fCachedSearch = false;
boolean fVectorResult = false;
Vector<- -> vecResult = new Vector<- ->();
if (result == null) {
return (result);
}
// if the servlet is advised not to do its own
// communication we return the result - - directly
// (in case of a vector we look for a ndCommunication- - as only
// element and return this)
if (!c_fSpecialCommunicationSupport)
{
if (result instanceof Vector<?>)
{
Iterator<?> iterator = ((Vector<?>) result).iterator();
while (iterator.hasNext()) {
vecResult.add((- -)iterator.next());
}
if (vecResult.size() == 1)
{
- - obj1 = vecResult.firstElement();
if (obj1 instanceof ndCommunication- -) {
return (obj1);
}
}
}
return (result);
}
// if this is a special search the result - - is a vector
// which contains two elements:
// 1. GeneralSearchDe- -ion- - (to describe the search)
// 2. Vector (result data)
if (result instanceof Vector<?>)
{
Iterator<?> iterator = ((Vector<?>) result).iterator();
while (iterator.hasNext()) {
vecResult.add((- -)iterator.next());
}
fVectorResult = true;
if (vecResult.size() == 2)
{
- - obj1 = vecResult.firstElement();
- - obj2 = vecResult.elementAt(1);
if ( (obj1 instanceof GeneralSearchDe- -ion- -)
&& (obj2 instanceof Vector<?>))
{
fCachedSearch = true;
}
}
}
// now in case of returning a vector we have to check the size
// against the given block size to support the transfer of
// large vectors in multiple data blocks
// -> this approach only makes sense for external requests due to
// -> slow data transfer...
if ((c_iMaxBlockSize > 0) && fVectorResult)
{
if (fCachedSearch)
{
Vector<?> vecData = (Vector<?>) vecResult.elementAt(1);
if (vecData.size() > c_iMaxBlockSize)
{
// in this case the second element (the data vector) has to be
// replaced by a vector containing the first data block of this vector
Vector<- -> vecNewData = new Vector<- ->();
// multi block transfer is necessary
// -> we have to encapsulate the data in a special communication
// -> - - which has to be used for these purposes
ndCommunication- - ndComm = new ndCommunication- -();
ndComm.setAccessKey(VectorStore.addVector(vecData));
ndComm.setMoreDataAvailable(VectorStore.getNextBlockFromVector(ndComm.getAccessKey(),
vecNewData,
c_iMaxBlockSize));
// fill in the new data block in the result vector
vecResult.removeElementAt(1);
vecResult.addElement(vecNewData);
ndComm.setDataCompressed(c_fUseCompressionForTransfer);
ndComm.setData(vecResult);
result = ndComm;
}
}
else
{
if (vecResult.size() > c_iMaxBlockSize)
{
// multi block transfer is necessary
// -> we have to encapsulate the data in a special communication
// -> - - which has to be used for these purposes
ndCommunication- - ndComm = new ndCommunication- -();
ndComm.setAccessKey(VectorStore.addVector(vecResult));
Vector<- -> vecData = new Vector<- ->();
ndComm.setMoreDataAvailable(VectorStore.getNextBlockFromVector(ndComm.getAccessKey(),
vecData,
c_iMaxBlockSize));
ndComm.setDataCompressed(c_fUseCompressionForTransfer);
ndComm.setData(vecData);
result = ndComm;
}
else if (c_fUseCompressionForTransfer)
{
// -> we have to encapsulate the data in a special communication
// -> - - which has to be used for these purposes (compression)
ndCommunication- - ndComm = new ndCommunication- -();
Vector<- -> vecData = vecResult;
ndComm.setDataCompressed(c_fUseCompressionForTransfer);
ndComm.setData(vecData);
result = ndComm;
}
}
}
// compress vector results on request
else if (fVectorResult && c_fUseCompressionForTransfer)
{
// -> we have to encapsulate the data in a special communication
// -> - - which has to be used for these purposes (compression)
ndCommunication- - ndComm = new ndCommunication- -();
Vector<- -> vecData = vecResult;
ndComm.setDataCompressed(c_fUseCompressionForTransfer);
ndComm.setData(vecData);
result = ndComm;
}
return (result);
}
/**
* Special method to handle multi block data transfer - this method
* fetches the next data block which is part of a vector.
*/
protected ndCommunication- - getNextDataBlock(ndCommunication- - ndComm) throws GeneralException
{
Vector<?> vecData = new Vector<- ->();
ndComm.setMoreDataAvailable(VectorStore.getNextBlockFromVector(ndComm.getAccessKey(),
vecData,
c_iMaxBlockSize));
ndComm.setDataCompressed(c_fUseCompressionForTransfer);
ndComm.setData(vecData);
return (ndComm);
}
...
И этот класс ndServlet вызывается в том коде, который я Вам показал выше, но только 1 раз:
GeneralServerAdapter_Servlet.setDefaultServletClass(ndServlet.class);
В остальном он используется только для репортов.
В ответ на:
куки не передаете

Ява-консоль пишет, что соединение с куками:
network: Connecting http://.../servlet.jar with cookie
network: Connecting http:/.../jakarta-oro-2.0.jar with cookie
security: Checking if certificate is in Deployment session certificate store
security: Checking if SSL certificate is in Deployment permanent certificate store
security: Possible use of Secure cookies blocked for
security: To use secure cookie (HTTPS), consider signing the application or host application with HTTPS
security: Possible use of Secure cookies blocked for https://.../servlet/de.novadata.pp.servlet.ndServlet
network: Connecting http://.../servlet/de.novadata.pp.servlet.ndServlet with cookie "JSESSIONID=A4C73477D9C1B454F601463D8C5F07A1"
Но у себя на компе я ни одного куки на эту темку не нашел
Эй, фуфло, готовься к шмону, ты на стрём поставлен у ворот... Присоединяйтесь: https://t.me/kudy_vadis
 

Перейти на