Shilpa Asuthkar

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

Recent posts by Shilpa Asuthkar

thanks Ulf Dittmer ,

with did not work i meant that the validation did not work as expected i mean its checking for string that starts with any of the letters or combination of letters in the list ie a b c x y z g h i seperately,sorry for not making it clear earlier. i have tried with the regular expression which u have suggested but this doesnot work as expected as well
18 years ago
hi all,
Can anybody please tell me how do we use a regular expression to validate when a field starts with any of the given strings say "abc","xyz","ghi"
i have tried this in validation.xml
<var-name>mask</var-name>
<var-value>^[^(abc)|(xyz)|(ghi)]]</var-value>
but this did not work
18 years ago
hi Waez,
check out the code i have given here.... if the filelength returns -1 u must try to read the data from the jar entry in chunks or set the filelength to some max value say 100 bytes.... replace temp.class with any file that u want to read

hope this code help you


import java.util.jar.*;
import java.io.*;
public class Readfromjar
{


public static void main(String[] args)
{
try {
FileInputStream fis = new FileInputStream ( "xxx.jar" );
JarInputStream j = new JarInputStream ( fis );


while ( true )
{
JarEntry entry = j.getNextJarEntry();
String elementName = entry.getName();
System.out.println(elementName);
if(elementName.equals("temp.class"))
{

File elementFile = new File("myfile");

int filelen = (int)entry.getSize();
//int filelen=100;
System.out.println(filelen);

byte[] wholeFile = new byte[ filelen ];
int bytesRead = j.read( wholeFile , 0 , filelen );

FileOutputStream fos = new FileOutputStream ( elementFile );
fos.write( wholeFile, 0, filelen );
fos.close();

j.closeEntry();

}

}

}
catch (IOException e) {

}


}
}
18 years ago
hope this will help u.....

<html>
<head>
<script language="javascript">
function meth()
{
document.getElementById("t1").value="SHILPA";
}
</script>
</head>
<body>

<form name="myform" action="temp1.jsp" onSubmit="return meth()">
<input type="hidden" name="t1" value='<%=request.getParameter("t1") %>' >
<input type="submit" value="submit" >

</form>
<% String str=null;
if(request.getParameter("t1")!=null)
str=request.getParameter("t1");
%>
<%= str%>
</body>
</html>


cheerss,
Shilpa
18 years ago
JSP
there is one solution to ur problem.....
store the javascript variable in a form field and then set it to the variable of in the jsp.... this form is a dummy form which on submit goes to javascript and the back to the same form
for example.......

<html>
<head>
<script language="javascript">
function meth()
{
var i=0;
i=i+1;
document.getElementById("t1").value=i;
}
</script>
</head>
<body>
<%! int x=0; %>
<form name="myform" action="temp1.jsp" onSubmit="return meth()">
<input type="text" name="t1" value='<%=request.getParameter("t1") %>' >
<input type="submit" value="submit" >

</form>
<% if(request.getParameter("t1")!=null) x=Integer.parseInt(request.getParameter("t1")); %>
<%= x%>
</body>
</html>

tough we r not supposed to use scripting in jsp but thats how u want want to set the value of x.....
hope this will help u.......
let me know...

regards,
Shilpa
18 years ago
JSP
if i have understood ur problem.......
when u submit the form and u come back to the same page then the already existing values for the 3 textboxes will also be passed to that page as parameters u can use request.getParameter
i am showing only a single text box as an example............


<html>
<body>
<form name="myform" action="temp1.jsp">
<input type="text" name="t1" value='<%=request.getParameter("t1") %>' >
<input type="submit" value="submit">

</form>
</body>
</html>

check out
on submit the value remains.....
18 years ago
JSP
hi all,
can anyboduy tell me how can we differentiate between required, minlenth or requiredif kind of validation errors(which are declared in the validator-rules.xml with depends attribute)....ie if i have a validate method in my form such that......

public ActionErrors validate(ActionMapping mp,HttpServletRequest req)
{
ActionErrors er=super.validate(mp,req);
--------
-------
}

now is it possible to retrive the error messages from attribute "er" and find out which type of validation error is it.... whether required,minlength etc
18 years ago
yes u r right
the compiler does complain about it......
i actually meant by handling the exception from the place where the subclass constructor is being called... n that was from main()--> where kartik instantiated the Test269 class.....
But Dilip i clearly wrote in the reply that.. becoz the default constructor of Test269 is internally calling the overloaded (no args) construtor of class A thats why it has to throw an exception as well
but a constructor which takes an arg as int need not throw Exception at all as it is not involved in the whole process( i mean it does not call the no args constructor of super class which throws an Exception)
not necessay....
it can even handle the exception in a try catch block
Hi Karthik,
you are right that a constructor can throw an exception...but any Exception that is thrown has to be caught.

but in your example..... u are calling a Test629 classes default constructor which inturn calls the overloaded constructor of class A,

And You know that the default constructor of class Test629 does not handle the Exception thrown by the overloaded constructor of class A, thus you are getting an error saying "the thrown Exception has to be caught or rethrown".
if u now change your code to this.....(u will not get any error)
public class Test629 extends A
{
Test629() throws Exception
{
System.out.println("B Class");
}

public static void main(String args[]) throws Exception{
Test629 t = new Test629();
}
}
class A
{
A() throws Exception
{
System.out.println("A Class");
}
}