Help coderanch get a
new server
by contributing to the fundraiser

Yong Ming Wai

Greenhorn
+ Follow
since Aug 31, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Yong Ming Wai

Hie,
I need to to round double value to a 2 decimal point value.However,
the value is to be round up instead round down as per default.
E.g : 2.142 -> 2.15 (default is 2.14)
or 2.1425 -> 2.15 (default is 2.14)
Code shown below return a round down value.
***********************************************
try {
DecimalFormat df = new DecimalFormat("RM#,###,###,###.00");
if (!val.equals(null) || !val.equals("")) {
val=df.format(val);
}
} catch (Exception e) {
System.out.println(String.valueOf(e));
}
return val;
**********************************************
Anyone have any idea?
Thanks~!!

18 years ago
hei evryone!


Does anyone knows how to solve this bug?

java.io.IOException: Corrupt form data: premature ending

Im using Oreilly's cos.jar MultipartRequest
here is my form :
function save()
{
var agree = confirm("Are you sure you wish to submit this form ?");

if (agree)
{
document.form1.action="../servlet/ehr.toll.ats.AtsGlcMultipartServlet";
document.form1.encoding = "multipart/form-data";
document.form1.al.value= "submit";
document.form1.sy.value= "EXTERNALCOURSEDIRNEW";
document.form1.submit();
}

}
<form name="form1" method="POST" action="" id="form1">

<table cellspacing=1 cellpadding=4 width="100%">
<tbody>
<TR>..............</TR>
<TR>..............</TR>
<TR>..............</TR>
<TR ALIGN="left" VALIGN="top">
<td class=bg6 width="30%"><span class="textb">Brochure Attachment</span></td>
<TD class=bg7><span class=textdata>File Name
<INPUT TYPE="file" NAME="fileName" SIZE="50" class="textdata" value="<%= fileName %>" ACCEPT="" >
</span></TD>
</tr>
<TR>..............</TR>
<TR>..............</TR>

</tbody>
</table>
</form>

HERE IS AtsGlcMultipartServlet which is a servlet :

package ehr.toll.ats;

import ehr.utility.*;
import ehr.classes.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
import java.sql.*;
import java.math.*;
import com.oreilly.servlet.*;
import com.oreilly.servlet.multipart.*;

public class AtsGlcMultipartServlet extends HttpServlet {

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}

/**
* @see javax.servlet.http.HttpServlet#void (javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException
{
try
{
MultipartRequest multi = null;
AtsGlcControlServlet atsGlcCtrl = new AtsGlcControlServlet();

String nextExtPage2 = "/ehr/toll/ats/glc/ATS_GLC_COURSE_DIRECTORY.jsp";

String nextPage = "";

String sy = "";
String al = "";

try
{
System.out.println("SecurityProperty.getFilesDirectory()-"+SecurityProperty.getFilesDirectory());

multi = new MultipartRequest(request, SecurityProperty.getFilesDirectory() + "ats", SecurityProperty.getMaxPostSize(), new com.oreilly.servlet.multipart.DefaultFileRenamePolicy());


}
catch (IOException ioe)
{
//ignore
System.out.println("error-"+ioe);
}

if (multi != null)
{
sy = Util.nullCheckStr(multi.getParameter("sy"));
al = Util.nullCheckStr(multi.getParameter("al"));

String syParam = "?sy=" + sy;
String syParam2= "&al=" + al;


System.out.println("sy-"+sy);
System.out.println("al-"+al);

if (sy.equals("EXTERNALCOURSEDIRNEW"))
{
if (al.equals("submit"))
{
request = AtsGlcControlServlet.atsGlcExtCrsDirMulti(request,"submit",multi);
request = AtsGlcControlServlet.atsGlcExtCrsDir(request, "view");
syParam = "?sy=EXTERNALCOURSEDIR";

nextPage = nextExtPage2 + syParam;
}
}
else
{
logOut(request, response, "nopage");
}
}
else
{
logOut(request, response, "nopage");
}
response.setContentType("text/html");
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
RequestDispatcher disp = getServletContext().getRequestDispatcher(nextPage);
disp.include(request, response);

}
catch(Throwable theException)
{
// uncomment the following line when unexpected exceptions
// are occuring to aid in debugging the problem.
if(SecurityProperty.getPrintStack())
{
theException.printStackTrace();
}
}
}
It able to upload the file into the directory.
However,the IOException causing other data insert to halt..
Searching on google doesn't provide much help..

Your response would be deeply appreciated.

alloy
18 years ago
dear all,

My company had a power trip and the UPS didnt kick it...
When the power restore,I realise that my server having problem..
it seems we unable to login into the page.....
Would appreciate for the help..asap
this is the error msg:

java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up certs for trusted CAs
at javax.crypto.b.<clinit>([DashoPro-V1.2-120198])
at javax.crypto.KeyGenerator.getInstance([DashoPro-V1.2-120198])
at ehr.utility.BlowFish.crypt(BlowFish.java:40)
at ehr.utility.BlowFish.encrypt(BlowFish.java:123)
at ehr.utility.SecurityControl.loginCheck(SecurityControl.java:86)
at ehr.login.login.performTask(login.java:36)
at ehr.login.login.doPost(login.java:16)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:644)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:287)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:371)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:793)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:719)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:687)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:263)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:154)
at com.ibm.servlet.engine.webapp.InvokerServlet.service(InvokerServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:644)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:287)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:371)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:793)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:719)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:687)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:263)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:154)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:105)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:217)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:155)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:300)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQEventListenerImp.java:230)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventListenerImp.java:104)
at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQEventSource.java:216)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(SQWrapperEventSource.java:354)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(SQWrapperEventSource.java:221)
at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(OutOfProcThread.java:248)
at java.lang.Thread.run(Thread.java:481)
java.lang.NoClassDefFoundError: javax/crypto/b
at javax.crypto.KeyGenerator.getInstance([DashoPro-V1.2-120198])
at ehr.utility.BlowFish.crypt(BlowFish.java:40)
at ehr.utility.BlowFish.encrypt(BlowFish.java:123)
at ehr.utility.SecurityControl.loginCheck(SecurityControl.java:86)
at ehr.login.login.performTask(login.java:36)
at ehr.login.login.doPost(login.java:16)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.servlet.engine.webapp.StrictServletInstance.doService(ServletManager.java:644)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet._service(StrictLifecycleServlet.java:160)
at com.ibm.servlet.engine.webapp.IdleServletState.service(StrictLifecycleServlet.java:287)
at com.ibm.servlet.engine.webapp.StrictLifecycleServlet.service(StrictLifecycleServlet.java:105)
at com.ibm.servlet.engine.webapp.ServletInstance.service(ServletManager.java:371)
at com.ibm.servlet.engine.webapp.ValidServletReferenceState.dispatch(ServletManager.java:793)
at com.ibm.servlet.engine.webapp.ServletInstanceReference.dispatch(ServletManager.java:719)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:687)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:263)
at com.ibm.servlet.engine.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:154)
at com.ibm.servlet.engine.srt.WebAppInvoker.doForward(WebAppInvoker.java:105)
at com.ibm.servlet.engine.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:217)
at com.ibm.servlet.engine.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:67)
at com.ibm.servlet.engine.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:106)
at com.ibm.servlet.engine.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:160)
at com.ibm.servlet.engine.oselistener.OSEListenerDispatcher.service(OSEListener.java:300)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp$ServiceRunnable.run(SQEventListenerImp.java:230)
at com.ibm.servlet.engine.oselistener.SQEventListenerImp.notifySQEvent(SQEventListenerImp.java:104)
at com.ibm.servlet.engine.oselistener.serverqueue.SQEventSource.notifyEvent(SQEventSource.java:216)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.notifyService(SQWrapperEventSource.java:354)
at com.ibm.servlet.engine.oselistener.serverqueue.SQWrapperEventSource$SelectRunnable.run(SQWrapperEventSource.java:221)
at com.ibm.servlet.engine.oselistener.outofproc.OutOfProcThread$CtlRunnable.run(OutOfProcThread.java:248)
at java.lang.Thread.run(Thread.java:481)
Thankz
19 years ago
Thanks for advice...

After few changes..i managed to get it done.
Unfortunately,new problems arise along..
My system has alot of folders which contain lots of servlets..(.class)
do i have to declare all of them and map it in web.xml one by one..

examples:

my login.jsp will post value to login.class(login folder) which will import util.class(in system folder) to use DCconnect() to verify the login..then..if valid..
login.class will call welcome.jsp

do i have to..
write...
< servlet > ...
< servlet > ...
< servlet-mapping > ...
< servlet-mapping > ... for all the servlet?
if kinda of troublesome,rite?
19 years ago
JSP
hie there..

i am new to JSP and tomcat...
what i understand about JSP is it used to display the output while the servlet will do the processing.

Here is basically what i wanna implement in my web application..

user->JSP(form)->pass the value to servlet(.java)->processing value(servlet)->pass the output to JSP->display out(JSP).

i know that all JSP files should put in ../tomcat/webapps/ROOT/
but how about the servlet?...i tried putting it in ../ROOT/WEB-INF/classes
but it gives me errors...

i check in Internet..and most of them told me that i should set the classpath of the servlet the i wanna use..i tried but still give me errors.

anyone?
19 years ago
JSP
<%
// I invalidate all my session when i logout and comes on Login.jsp page but if i go back still it open
previous pages
How i can stop these
i am adding these line in avery jsp page
1)
response.setHeader("Pragma","no-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>

2) and in Logout.jsp
session.invalidate();
response.sendRedirect("Login.jsp");

still on reaching login page i can move to previous page by clicking back button
19 years ago
JSP
ah!!i am banging my head against the wall while writing this..
I am so careless...
Thank you so much..gregg...
I really appreciate ur patience and help towards such minor problem..
hehehehe...Thankz!!!
19 years ago
JSP
sheesh...thats mean..hehehe..my fault anyway..
sorry for that...everyone...
here's the code..
<html>
<head>
<title>My First JSP</title>
</head>
<body>
<%@ page import="java.sql.*" %>
<%
String connectionURL = "jdbc:mysql://localhost:8080/tailo";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>

<html><body>

<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM dvd");

while (rs.next()) {
out.println(rs.getString("title")+"<br>");
}

rs.close();
%>

</body></html>
19 years ago
JSP
i am using MySQL-connector-java 3.0.15,Tomcat 4.1,J2SDK 1.4.0

i am getting the following error: please help me in sorting it out javax.servlet.ServletException: Communication link failure: java.io.EOFException, underlying cause: null ** BEGIN NESTED EXCEPTION ** java.io.EOFException
Thankz
19 years ago
JSP
hie everyone..
i am final year student major in Software Engineering..
I need a good topic for my final project..
Anyone care for a piece of idea?
I really prefer not to do any website development..heh!
19 years ago
hie everyone..
i am final year student major in Software Engineering..
I need a good topic for my final project..
Anyone care for a piece of idea?
I really prefer not to do any website development..heh!
19 years ago
JSP
I am just beginner in JAVA..
Can i know any website or ebook for learning JSP?
20 years ago
JSP