Inserting & in oracle  

Posted by Kishore in

If there are any & symbol in your sql insert query value, replace it with &'||'. (In case if the query fails to run)

The & will be considered as beginning of variable name in Oracle SQL.

Note: This is only if the & symbol is inside quotes.


Insert into temp values(2.’me&u’); è Insert into temp values(2.’me&’||’u’);

Searching inside the Oracle Functions/Packages/Procedures  

Posted by Kishore in

To search a text inside a oracle database function or package, We can use this query

select * from USER_SOURCE where upper(TEXT) like '%search text%'

USER_SOURCE describes the text source of the stored objects owned by the current user. Its columns (except for OWNER) are the same as those in "ALL_SOURCE".

@ and " are swapped?  

Posted by Kishore in

Oh God. This is a terrible problem i had.

Whenever i pressed @ key in laptop, " came as output. and vice versa.

But the Solution was damn simple.
Someone changed the Keyboard country setting to UK, Just change it to US. Thats all.

Number restriction in textbox using javascript  

Posted by Kishore in

I have a developed this simple javascript to allow user to key in only numerics and dot(for decimals).

function verify(e)
var zero=48;
var nine=57;
var dot=46;
if((e.keyCode==dot)||(e.keyCode>=zero && e.keyCode<=nine)){
return true;
return false;

Best example for Javamail  

Posted by Kishore in ,

I have found a wonderful sample of javamail in here

Apache Service not running in port 80  

Posted by Kishore in ,

I have been trying to learn php and MySQL stuff for hosting my own website. I will write a separate post on how to configure and initial settings.

But main problem all will encounter will be the port 80 already running.

If any other service runs in port 80, then the apache server service wont start. It will keep begging you to clean port or change port.

The one simple solution is to change the listen port in the httpd.conf
Change Listen 80 to Listen 90. Here the port 90 can be anyother free port.

If not and you desperately wanted to change the port, then you need to scan all your ports. Check which process is using port 80 and kill it.

The one of the best freeware command prompt port scanner i use is fport.

Use it to find the port, and stop the process. Continue with your port 80. :)

FileUpload in JSP  

Posted by Kishore in ,

Its been so long since i last blogged.
This time i am coming up with how to upload files in jsp.

The first and formost thing before doing this is to have the necessary framework to do this uploading.

You can use Apache Common FileUpload or com.oreilly.servlet.

Here i have used the second one.

In the jsp, the form should have the multipart encoding. To do this, please follow the following HTML snippet.

<form action="../AddCandidateServlet" method="post" enctype="multipart/form-data">

But if you do this, then the normail request.getParameter(str) will not be capable of reading the file or other input values from the particular form, so in order to do that specific task, we need to use the external frameworks.

The following example doPost method, reads all parameters and values. Also it stores the file in the specified location.

The following code is not my code, its been extracted from the site.

* Example servlet to handle file uploads using MultipartParser for
* decoding the incoming multipart/form-data stream

import javax.servlet.*;
import javax.servlet.http.*;

import com.oreilly.servlet.multipart.*;

public class DemoParserUploadServlet extends HttpServlet {
private File dir;

public void init(ServletConfig config) throws ServletException {
// Read the uploadDir from the servlet parameters
String dirName; //= config.getInitParameter("uploadDir");
dirName="C:\\Program Files\\Apache Group\\Tomcat 4.1\\webapps\\examples\\WEB-INF\\classes\\cal";
//if (dirName == null) {
// throw new ServletException("Please supply uploadDir parameter");
dir = new File(dirName);
if (! dir.isDirectory()) {
throw new ServletException("Supplied uploadDir " + dirName +
" is invalid");

public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
PrintWriter out = response.getWriter();
out.println("Demo Parser Upload Servlet");

try {
MultipartParser mp = new MultipartParser(request, 1*1024*1024); // 10MB
Part part;
while ((part = mp.readNextPart()) != null) {
String name = part.getName();
if (part.isParam()) {
// it's a parameter part
ParamPart paramPart = (ParamPart) part;
String value = paramPart.getStringValue();
out.println("param; name=" + name + ", value=" + value);
else if (part.isFile()) {
// it's a file part
FilePart filePart = (FilePart) part;
String fileName = filePart.getFileName();
if (fileName != null) {
// the part actually contained a file
long size = filePart.writeTo(dir);
out.println("file; name=" + name + "; filename=" + fileName +
", filePath=" + filePart.getFilePath() +
", content type=" + filePart.getContentType() +
", size=" + size);

else {
// the field did not contain a file
out.println("file; name=" + name + "; EMPTY");
catch (IOException lEx) {
this.getServletContext().log(lEx, "error reading or saving file");

// If the next two lines are giving errors, you can comment it. But you will not be able to some other works with it.
CommandProcessor cp=new CommandProcessor();

HttpSession session=request.getSession();
String fname=(String)session.getAttribute("FILENAME");
out.println("returned from cp"+fname);