amit malhotra

Ranch Hand
+ Follow
since Aug 06, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by amit malhotra

Hello,
open source technologies are really great, have been following up struts for a long time now, but in my opinion they come with a cost, they are not properly documented and beginning them is really tough,
if we do have proper documentation for beginners then they would really be unbeatable...
hello,
i am writing a jsp application which is in two frames, am using the upper frame as a menu with buttons on the left and right hand side...
the buttons on the left are the modules that i have ,i.e Master, WBS and Misc
and the buttons on the right are standard add,delete, append.. functions
what i want is when i click on Master the action page for add, delete and append should be say x.jsp, y.jsp and z.jsp
and when i click WBS the action page for add, delete and append should be say a.jsp,b.jsp and c.jsp.. and so on
could some one help me out
rgds
amit
22 years ago
JSP
hello,
i am writing a jsp application which is in two frames, am using the upper frame as a menu with buttons on the left and right hand side...
the buttons on the left are the modules that i have ,i.e Master, WBS and Misc
and the buttons on the right are standard add,delete, append.. functions
what i want is when i click on Master the action page for add, delete and append should be say x.jsp, y.jsp and z.jsp
and when i click WBS the action page for add, delete and append should be say a.jsp,b.jsp and c.jsp.. and so on
could some one help me out
rgds
amit
i have loaded a tomcat(4.0.1 ) into IIS but the problem is that for showing my home page i have to type in the port number ie 8080, like http://jginrtanet:8080/welcome.jsp
or http://jgintranet:8080/ and then the jsp pages appear, infact for any JSP page i have to type in the port number, how can i avoid typing the port number, is there any way out for this
22 years ago
i have loaded a tomcat(4.0.1 ) into IIS but the problem is that for showing my home page i have to type in the port number ie 8080, like http://jginrtanet:8080/welcome.jsp
or http://jgintranet:8080/ and then the jsp pages appear, infact for any JSP page i have to type in the port number, how can i avoid typing the port number, is there any way out for this
22 years ago
i am trying to upload a file using servlets given in in a book the congifuration and all is done when i try to run the code the error i get is
An unexpected error has occoured
Error description :java.lang.StringIndexOutOfBoundsException: String index out of range: -1
could some one tell me why, it is really urgent
thanx,bye
23 years ago
friends i am stuck up at a particular place,please tell me as to how should i proceed in this case..
i am writing a code for file upload and the code is as it is given in a serlverts book by dustin callaway, the code is not working at my end....could some one please tell me a way out
i am on tomcat 3.2.1
here are the file, an html page and a servlet, the servlet has been compilied
html form
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>File Upload Example</title>
</head>
<body style="font-family: Verdana; font-size: 10pt" background="file:///D:/jakarta-tomcat-3.2.1/jakarta-tomcat-3.2.1/webapps/fileupload/BACKGROUND1.jpg">

<h4 align="center"><font color="#000080"><u>File Upload Servlet</u></font></h4>
<table border="0" width="84%" cellspacing="0" cellpadding="0">
<tr>
<td width="51%">

<form enctype="multipart/form-data" action="UploadServlet" method="post">
<p><font color="#000080">Press the <b> browse</b> button to select the file to upload and then click on the <b>Upload Button</b>
</font>
<p>
<font color="#000080">
 

<input type="hidden" name="directory" value="temp/" >
<input type="hidden" name="successPage" value="success.html">
<input type="hidden" name="OverWrite" value="false">
<input type="hidden" name=OverWritePage" value="overwrite.html">
</font></td>
<td width="50%">
<p align="center"><font color="#000080">
<br>
<input type="file" name="filename" value="" maxlength="255" size="50">
<br>
<br>
<input type="submit" value="Upload">
</font></p>
</td>
</tr>
</table>
</form>
</body>
</html>
servlet code
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class UploadServlet extends HttpServlet
{
static final int MAX_SIZE =102400;
String rootPath,successMessage;

public void init(ServletConfig config) throws ServletException
{
super.init(config);
rootPath = config.getInitParameter("RootPath");
if (rootPath == null)
{
rootPath="/";
}
successMessage = config.getInitParameter("SuccessMessage");
if (successMessage == null)
{
successMessage = "File Upload Complete ";

}
} // end of init() method


public void doPost(HttpServletRequest request,HttpServletResponse response)
{
ServletOutputStream out = null;
DataInputStream in = null;
FileOutputStream fileOut = null;

try
{
response.setContentType("text/plain");
out=response.getOutputStream();
} catch(IOException e)
{
System.out.println("Error getting the output stream");
System.out.println("Error description:"+e);
}
try
{
String contentType = request.getContentType();
if (contentType != null && contentType.indexOf("multipart/form-data") != -1)
{
in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
if (formDataLength > MAX_SIZE)
{
out.println("Sorry the file is too large to uploaad ");
out.flush();
return;
} // end of if

byte dataBytes[] = new byte[formDataLength];
int bytesRead=0;
int totalBytesRead=0;
while (totalBytesRead < formDataLength)
{
bytesRead = in.read(dataBytes,totalBytesRead,formDataLength);
totalBytesRead += bytesRead;
} // end of while

String file = new String(dataBytes);
dataBytes = null;
int lastIndex = contentType.lastIndexOf("=");
String boundary =contentType.substring(lastIndex+1,contentType.length());
String directory="";
if(file.indexOf("name =\"Directory\"") > 0);
{
directory = file.substring(file.indexOf("name=\"Directory\""));
directory=directory.substring(directory.indexOf("\n")+1);
directory = directory.substring(0,directory.indexOf("\n")-1);
if (directory.indexOf("..")>0)
{
out.println("Security Error: You cannot do this ");
return;
}
}// end of if
String successPage="";
if(file.indexOf("name=\"SuccessPage\"")>0)
{
successPage=file.substring(file.indexOf("name=\"SuccessPage\""));
successPage=successPage.substring(successPage.indexOf("\n")+1);
successPage=successPage.substring(successPage.indexOf("\n")+1);
successPage = successPage.substring(0,successPage.indexOf("\n")-1);
}
String overWrite;
if(file.indexOf("name=\"OverWrite\"")>0)
{
overWrite = file.substring(file.indexOf("name=\"OverWrite\""));overWrite = overWrite.substring(overWrite.indexOf("\n")+1);
overWrite = overWrite.substring(overWrite.indexOf("\n")+1);
overWrite = overWrite.substring(0,overWrite.indexOf("\n")-1);
}else // end of if
{
overWrite="false";
}// end of else
String overWritePage="";
if (file.indexOf("name=\"OverwritePage\"")>0)
{
overWritePage=file.substring(file.indexOf("name=\"OverWritePage\""));
overWritePage = overWritePage.substring(overWritePage.indexOf("\n")+1);
overWritePage = overWritePage.substring(overWritePage.indexOf("\n")+1);
overWritePage = overWritePage.substring(0,overWritePage.indexOf("\n")-1);
}
String saveFile = file.substring(file.indexOf("filename=\"")+10);
saveFile=saveFile.substring(0,saveFile.indexOf("\n"));
saveFile = saveFile.substring(saveFile.lastIndexOf("\\")+1,saveFile.indexOf("\""));
int pos;
pos = file.indexOf("filename=\"");
pos = file.indexOf("\n",pos)+1;
pos=file.indexOf("\n",pos)+1;
int boundaryLocation = file.indexOf(boundary,pos)-4;
String fileName = new String(rootPath+directory+saveFile);
File checkFile = new File(fileName);
if (checkFile.exists())
{
if (!overWrite.toLowerCase().equals("true"))
{
if (overWritePage.equals(""))
{
out.println("Sorry the file already exists");
}else // end of if
{
response.sendRedirect(overWritePage);
} // end of else
return ;
}// end of if
} // end of if

File fileDir = new File(rootPath+directory);
if (!fileDir.exists())
{
fileDir.mkdirs();
} // end of if
fileOut = new FileOutputStream(fileName);
fileOut.write(file.getBytes(),0,file.length());

if (successPage.equals(""))
{
out.println(successMessage);
out.println("File Written to "+fileName);
}else // end of if
{
response.sendRedirect(successPage);
}
}else
{
out.println("Request not multipart/form data");
}
} catch(Exception e)
{
try
{
System.out.println("Error in do Post:"+e);
out.println("An unexpected error has occoured");
out.println("Error description :"+e);
}catch(Exception ex)
{
}
finally
{
try
{
in.close();

}catch(Exception ex)
{
}
try
{
out.close();

}catch(Exception ex)
{
}
}
}
any sugessions will be of gr8 help
23 years ago
Hello Sanjay,
i will try out the same hope it works out, I was trying to pass the param in the same way but was unsuccessful, will rey out again
23 years ago
hello friends,
here is a little problem that i have please see if you can fix it
<html>
<head>
<title>Project Life Cycle</title>
<script>
function buttonEvents(){
document.forms[0].action="success.jsp";
document.forms[0].submit()
}

function buttonEvents1(){
document.forms[0].action="querycontent.jsp";
document.forms[0].submit()
}

function openWindow(){
open("path.jsp'","sayings","menubar=0,scrollbar=0, resizable=0, width=250,height=250,top=150, left=400")
}
</script>
</head>
<%@ page import="java.sql.*" %>

<body style="font-family: Verdana; font-size: 10pt; color: #000080" background="BACKGROUND1.jpg">
<table border="0" width="780" cellspacing="0" cellpadding="0" height="68">
<tr>
<td width="100%" height="68">
<table border="0" width="100%" height="75" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" background="HEADER1.jpg" height="69"> </td>
</tr>
</table>


<h3 align="center" >Project Life Cycle</h3>
<form name="feedbackform" method="post">
<div align="center">
<table border="1" width="650" style="font-family: Verdana; font-size: 10pt>


<tr>
<td align="center" ><b></b></td>
<td align="center" ><b>PID's</b></td>
<td align="center" nowrap><b>Equip List</td>
<td align="center" nowrap><b>Line List</td>
<td align="center" nowrap><b>Inst List</td>
</tr>
<%
String tableselected;
String driver="sun.jdbc.odbc.JdbcOdbcDriver";
String protocol="jdbc dbc:db2";
//Connection conn = null;
//Statement stmt = null;
ResultSet rs = null;
String sqlquery ="SELECT * FROM crude ";
Class.forName(driver);
Connection conn=DriverManager.getConnection(protocol);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sqlquery);

while(rs.next()){
String PID_PATH = rs.getString(1);
String PID_311 = rs.getString(2);


%>
<tr>
<td align="center" width="50%">
<input type="submit" name="pid" value="<%= PID_311 %>" onClick="openWindow()"></td>
<td align="center"><input type="checkbox" name="amit" value="<%= PID_311 %>"></td>
<td align="center"><input type="checkbox" name="amit" value="<%= PID_311 %>"></td>
<td align="center"><input type="checkbox" name="amit" value="<%= PID_311 %>"></td>
</tr>
<%
}
%>
<tr>
<td> </td>
<td align="center"><input type="submit" value="Status" name="B1"onClick ="buttonEvents()">    <input type="submit" value="Doc" onClick ="buttonEvents1()"></td>
<td align="center"><input type="submit" value="Status" name="B2">    <input type="submit" value="Doc"></td>
<td align="center"><input type="submit" value="Status" name="B3">    <input type="submit" value="Doc"></td>
</tr>
</TABLE>

</div>
</form>
</body>
</html>
in the function openWindow() i am opening a pop up window called
path.jsp, i want to pass a parameter to it say PID_PATH
how do i do it ,please tell me as i have tried all the options
thanx
23 years ago
Hello Friends,
How can I populate my selection box values from database,please help me out
23 years ago

Originally posted by Tim Holloway:
[B]
The TLD which is a part of dg tag library is given in the package itself and i have installed it correctly, could there be any other reason

23 years ago
Hello,
I have just downloaded dbtags library and have followed the installation
instruction given in the documentation, I am working with version 3.2.1 of
tomcat but when I run the sample code which i have copied from the
documentation, it gives me an error and the error is as shown below
apache.jasper.compiler.CompileException:
D:\jakarta-tomcat-3.2.1\jakarta-tomcat-3.2.1\webapps\ROOT\taglibrary.jsp(0,0)
Unable to open taglibrary http://jakarta.apache.org/taglibs/dbtags : Could not
locate TLD META-INF/taglib.tld
could you please tell me what's wrong
23 years ago
Hello everyone,
i am displaying a table from a database and want to include a print button on the same page so that the user can click it instead of going to file-->print options ,on clicking this button the normat options of propoerties should appear....
could someone suggest a way out.
23 years ago

Originally posted by Yogen Vadnere:
Hello Yogen,
thanx a lot for your script , it did work and i am using it in one of my projects....and finally relieved me of the stress i was undergiong for 3 days.
thanx,

23 years ago
thanx a lot for the reply i will try out the changes now itself and mail you back

Rgds
Amit
23 years ago