pradeepktg 0 Light Poster

Hi All,

I want to know how to avoid inserting multiple records. Below is my case;

(1) I have a jsp page - when a timer for a particular product reaches 3 mins, i am getting that particular productid and sending the productid through ajax

(2) in the ajax script, i am getting the product id and redirecting to a jsp page

(3) in that jsp page, i am inserting a record to a table for that particular productid. Everything works fine, but many records are inserting, i just want to insert only one record.

It would be great if any one can help on how to stop or avoid inserting multiple records.

Thanks,
Pradeep

pradeepktg 0 Light Poster

Hi, I have developed application in jsp and apache tomcat. How to achieve extension less url? For eg, if have http://www.xxx.com/yyy.jsp as http://www.xxx.com/ and http://www.xxx.com/user/yyy.jsp as http://www.xxx.com/user/

pradeepktg 0 Light Poster

Hey Guys,

Thanks for your help. It works perfectly!!!

Hi javaAddict,

This is how i redirect.

<%
try
{
String strSessionUser = session.getAttribute("regusername").toString();
}
catch(Exception e)
{
%>
<script>
adminhome.expmsg.value='Please login';
adminhome.action="index.jsp";
adminhome.submit();
</script>
<%
}
%>
pradeepktg 0 Light Poster

Hi All,

I have developed a application in jsp. I need to achieve a count down timer(days,hours,minutes,seconds) between from date to todate, considering below cases.

All below are assumed

(1) I have 4 product, for each product i have different end date stored in mysql in DB.

(2) I need to calculate time time remaining for the end date for each product, for eg;

Product 1 end date : 10/05/2010 (i need to show the time remaining for the end of 10/05/2010 from current time and date). Like wise i need to show for different products.

How to achieve this. Solutions for this would be highly appreciated. Thanks in advance.

pradeepktg 0 Light Poster

Can you post code on how you redirect?

Hi javaAddict,

This is how i redirect.

<%
try
{
String strSessionUser = session.getAttribute("regusername").toString();
}
catch(Exception e)
{
%>
<script>
adminhome.expmsg.value='Please login';
adminhome.action="index.jsp";
adminhome.submit();
</script>
<%
}
%>
pradeepktg 0 Light Poster

Hi All,

I have developed a web application using jps. I have a user pages, which can be accessed after entering login credentials. If a user tries to go the a certain page directly without logging in, it directs to login page, this works perfectly in all browsers except mozilla.

I have created session in all pages and checking if session is null or not, but still the users goes directly without logging in into a page where login credentials required. This is a major problem in mozilla. How to overcome this problem. Any solution regarding this would be appreciated.

Thanks

pradeepktg 0 Light Poster

Thanks Guys ! It works perfectly !!! I really appreciate the solution/idea given by you people!!!

pradeepktg 0 Light Poster

What are you trying to do? See which values are repeated in the arrays?

I am just trying to compare the values between prodValues and prodValues1. Eg, if 0.1 is in prodValues and if same value also in prodValues1, i'll print that as "Unique" else "not unique".

pradeepktg 0 Light Poster

Hey guys,

Special thanks to peter_budo and genevish. After several fights, it wroks fine. Again am facing problem in comparing values between two arraylist. I have successfully converted array list into array. If i use for loop, 1st array values are prints properly, in 2nd array only the 1st element is printed. Just heck the below link.

prodValues = (String[])arr.toArray(new String[arr.size()] );
prodValues1 = (String[])ar.toArray(new String[ar.size()] );

 for(int j=0;j<=prodValues.length;j++)
	  {
                        strabc=prodValues[j];
			 prodValuesint=Float.parseFloat(strabc);
		 for(int i=0;i<=prodValues1.length;i++)
			  {
                     	  strabc1=prodValues1[i];
                         prodValuesint1=Float.parseFloat(strabc1);
if(prodValuesint1==prodValuesint)
{
out.println("Unique");
}
else if(prodValuesint1!=prodValuesint)
{
out.println("Not Unique");
}
			 }
					
	  }

My case is, i have stored unique values in "prodValues" and converting that as array and am converting each array element into float, above procedure is done for prodValues1 also. prodValues1 is the particular user values.

How to compare this?

pradeepktg 0 Light Poster
//rs is the resultset

ArrayList ar=new ArrayList();

while(rs.next())
{
    String strprodvalue = rs.getString("prodvalue");
    out.println(strprodvalue);
    ar.add(strprodvalue);
}

int size = ar.size();
String[] prodValues = ar.toArray();

Thanks! But am getting this error "Type mismatch: cannot convert from Object[] to String[]"

pradeepktg 0 Light Poster

You can do all above with ArrayList. However if you insist no conversion and working with array then, ArrayList class documentation will tell you that you are provided with method size(), toArray() or with toArray(T[] a)

Hey peter_budo,

Can u give me sample code for the above case? It would be great help.

pradeepktg 0 Light Poster

Hi All,

Thanks for ur input! Thanks to peter_budo for providing me solution and thanks to genevish for solution n code. But guys, i need to store "strprodvalue" values in array and i need to find the lenght of that array and i need to compare the values.

pradeepktg 0 Light Poster

Try this:

//rs is the resultset

ArrayList ar=new ArrayList();

while(rs.next())
{
    String strprodvalue = rs.getString("prodvalue");
    out.println(strprodvalue);
    ar.add(strprodvalue);
}

ar is an ArrayList that has all of the values. Note that you don't need to know how many values there are ahead of time.

Hey genevish,

Thanks! It works fine. but i want to know the length of the array and i need to compare the values in the array. How to achieve this?

pradeepktg 0 Light Poster

Hi All,

How to store the resultset value in a array? I have a field "prodvalue" in DB Table, now i want to store this "prodvalue" in array. Am able to print the values of "prodvale" in jsp, but not able to store in array.

Pl. find below the code, so that you can understand more easily.

rs is the resultset
while(rs.next())
{
String strprodvalue=rs.getString("prodvalue");
out.println(strprodvalue);
}

The above code displays all the prodvalues, but in want to store strprodvalue in array. How to do this??

Thanks,

pradeepktg 0 Light Poster

Hi All,

I have a database table "productdetails",where i have id,name,price,prodimage(blob) fields.

Am displaying all the records using jsp inside a div with the help of while loop, am getting all the datas correctly except the image.

Check below code and let me know how to display the image retrieved from databse inside a img tag.

<%
rs = s.executeQuery("select * from productdetails"); 
while(rs.next())
{
%>
<div><%=rs.getString("id")%>
<div><%=rs.getString("name")%>
<div><%=rs.getString("price")%>
<img src="<%=rs.getString("prodimage")%>" />
}
pradeepktg 0 Light Poster

Pradeepktg,

If "solved" then could you please mark the topic as such.

Thanks
Airshow

Hi Airshow,

Sorry for not marking the thread as "solved". Since am a new user, i dont know how to mark this thread as solved. It would be better if you can assist me on this.
Thanks,

pradeepktg 0 Light Poster

Pradeepktg,

Use parentNode rather than parentElement . This will work in both browsers without needing to branch.

Airshow

Airshow,

Thats for your effort. I made it work in other way,ofcourse using parentNode. The posted code was bit complicated. I made it easier n it all worked fine.
Thanks,

pradeepktg 0 Light Poster

Hi,

I want to remove the current DOM using tagName=DIV. Below function works fine in IE but not working properly in mozilla. The 'if' part is for IE and 'else' part is for mozilla FF. In 'else' part,The current DIV is not removing, only the DIV at position 1,that is the div at the first element in the array is removed.

Kindly anybody give me solution on how to remove the current childelement in mozilla.

function removeit(e)
{

if (window.event) 
{ 
var current = window.event.srcElement;
while ( (current = current.parentElement)  && current.tagName !="DIV");
 current.parentElement.removeChild(current);
}

else
{
var current = e.target;
var element = document.getElementById("moreUploads"); // its a div 
while (element.childNodes[0])  {   
 element.removeChild(element.childNodes[0]);
 removeChildNodes(element);  }
}

}
pradeepktg 0 Light Poster

Ok guys, i got the solution couple of days ago itself. Sorry for the delay confirnation from myside.

Thanks,
Pradeep

pradeepktg 0 Light Poster

Hi All,

I want to use jquery overlay in one of my dynamic page. Well, let me explain the case in detail;

Actually i have implemented in my site, but it works for only one id.

Ok, here is the case

(1)I have a news page, which is dynamically loaded(used jsp), in news.jsp page, all the news titles is loaded from DB, each news title has a unique ID

(2) When i click the news title, id will be passed to show.jsp page and the detailed news for the corresponding id will be opened in a seperate window.

Now;
(1) When i click news title in news.jsp page, i want to use jquery overlay instead of opening in a window.

Actaully, i implemented it, but it works only for one id until the news.jsp page is refreshed.

Here goes my code:

<a style="cursor:hand; color:#0000ff" class="grey11" href="show.jsp?id=<%=id%>" rel="#overlay"  >
		 
						  
                            <%
out.println("<span ><u>"+newstitle +"</u></span>");	
%>

jquery script:

$(function() {     
	$("a[rel]").overlay(function() {
	var wrap = this.getContent().find("div.wrap");
	if (wrap.is(":empty")) {
	wrap.load(this.getTrigger().attr("href"));
	}
});

}) ;

Could anyone tell me why its opening only for one id?

pradeepktg 0 Light Poster

Hi,

Can anybody send me the code for selecting image from system through multipart/form. Once it is selected, there should be option for cropping with preview. There are lots of cropping codes in internet, but i couldn't find anything with jsp(all are in php and javascript). I need it in complete javascript or javascript + jsp.

MyCase:

In my jsp form, i have a digital signature uploading(jpg,gif,png), once the user selects the digital signature from the local system, he/she submits the form through submit button. URL/PATH will be saved in DB and image will be saved in server.

Solution required:

Before submitting the form, there should be a option for cropping the digital signature. Once the cropping is completed, only the cropped image should be saved in server and not the original image.

It would be great help if somebody can send the code.

Thanks,
Pradeep

pradeepktg 0 Light Poster

Ok. Thanks Atli ! Is there any other options like mysql_affected_rows() as in php???

pradeepktg 0 Light Poster

Hi Alti,
row_count() is working properly in command prompt, but whereas in query browser,it always shows -1 value even after records are updated successfully.

I would be better if u can give sample code on how to get row_count value in front end.

Thanks,

pradeepktg 0 Light Poster

Hi bhanu1225,

Thanks! Actually, am trying to update a record say: update tbl_name set name='bhanu1225' where name='pradeep' and id='1';

If the update is success, i want to print a messgae 'successfully updated' in frontend. For this i want to know if a record is updated in database or not. Am using mysql and jsp.

Thanks,

pradeepktg 0 Light Poster

Hi,

How to find number of rows affected in update statement using mysql (not using php mysql).

Thanks,
Pradeep

pradeepktg 0 Light Poster

No, if a file is not present in local machine we cannot select. But after selecting a file from local machine and before submitting the form, user may change/delete/rename the source file. So the form will upload blank file.

After selecting and before submitting the form, i want to check if file is still in the same location.This is what am trying convey.

But many of the guru's answer was impossible, only way is using FSO ActiveX control.

Thanks,

Is it posibble to select a file using html form tag if file is not present in your local machine?

pradeepktg 0 Light Poster

Hi All,

I guess, its really hard to check if a selected file(html file control) exist in the same location(local system) using javascript other than using FSO. I would like to know is it possible to check using ajax and jsp,checking after submitting the form. If yes, pl.send me the sample code...

pradeepktg 0 Light Poster

Hi ShawnCplus,

Thanks for your reply.
Once the user selects the file, we need to check in the back end process before submitting the form(through ajax) . Am using JSP as back end. is it possible achieving this???

If so, pl send me the sample code. Thanks!

Yeah... you can't do that. It's up to the user. You can't and will never be able to have direct interaction with the user's filesystem outside of creating cookies.

All you can do is check AFTER they submit the form to see if you got any errors during upload.

pradeepktg 0 Light Poster

Hi All,

Am new to this forum and really happy to share my programming thoughts to you all.

It would be great help if some body gives me the the solution for the below.

Case:

When i select a file (through html file control) from local machine, before uploading i want to check if the selected file exist(because,after selecting and before submitting the form,user may change the name/delete the file from the source). so after selecting the file, i need to check the same file exist as it is using javascript/ajax. Back end is JSP.

Eg: Am selecting abc.jpg from my system and changing the file name form the source as abcd.jpg, now abc.jpg does not exist. But i want to check if exist. If selected file does not exist, i want to display a message before uploading/submitting the form.

Thanks,