File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes calendar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "calendar" Watch "calendar" New topic
Author

calendar

archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
I have to display calendar in date field of this servlet .How to display it in my code?
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 1000
    
    2
please use code tags.
to display calendar you can use java script.
have a google search for javascript calendar.

Hope this helps.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
how to insert daatbase values from database to drop down list in servlet?
Eshwin Sukhdeve
Ranch Hand

Joined: Mar 15, 2012
Posts: 80

try withis..check with the syntex

ResultSet rs = stmt.executeQuery("Select * from table");
out.println ("<select>");
while(rs.next()){
out.println(" <option value="+rs.getString("name")+"></option>")

}
%>
out.println ("<select>");
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
i have tried it but it does not work....
Eshwin Sukhdeve
Ranch Hand

Joined: Mar 15, 2012
Posts: 80
what error you are getting and can you paste that code..
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
I am not getting any error but no item is displayed in drop down box......


String userName = "";
String password = "";
Connection con = null;
String url = "";
Class.forName ("");
con= DriverManager.getConnection (url, userName, password);



This is code
out.println("<select name=\"select5\">");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("Select NO from Emp1" );
while(rs.next())
{
out.println(" <option value=\"+rs.getString(\"NO\")+\"></option>");
}
out.println("</select>");
Eshwin Sukhdeve
Ranch Hand

Joined: Mar 15, 2012
Posts: 80
archana do one thing..take StringBuffer or StringBuilder and append all the option values in this.means dont execute out.println every time and after that send to
out.println;
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

You got no errors and no display, so have you debug the database values are being retrieved correctly before put it into <select>?


No pain, No gain.
OCJP 1.6
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:You got no errors and no display, so have you debug the database values are being retrieved correctly before put it into <select>?

means
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

I meant to say debug can help to check out the DB values are extracted properly.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:I meant to say debug can help to check out the DB values are extracted properly.


how to debug oracle database???
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Have to debug your Servlet code that extracts values from DB. Eclipse or other IDE would be very helpful for you to debug.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:Have to debug your Servlet code that extracts values from DB. Eclipse or other IDE would be very helpful for you to debug.


i have tried it also.........but does not work
Arunkumar Chinnadurai
Ranch Hand

Joined: Dec 15, 2011
Posts: 56

Hi every body ,

my suggestion is please use javascript callender.

Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

First thing is, there is a better way to display the page you are trying in the code above, go for a JSP.
Then you can use Javascript for the calender and Java beans for DB values.
Really helps in keeping things simple and maintainable.


SCJP, SCWCD.
|Asking Good Questions|
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Have you got values from DB while debugging? Is the problem about to display the content retrieved?
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:Have you got values from DB while debugging? Is the problem about to display the content retrieved?


yes problem is about to display the content retrieved
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Amit Ghorpade wrote:First thing is, there is a better way to display the page you are trying in the code above, go for a JSP.
Then you can use Javascript for the calender and Java beans for DB values.
Really helps in keeping things simple and maintainable.

i have to use only servlet for my project .so please hely me to use calendar in servlet and how to retrieve values from database to drop down box in my pdf.java servlet.
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Seems you have to give some text to display as caption in the <option> tag while value attribute would be sending the given value to server. Try this

out.println(" <option value=\"+rs.getString(\"NO\")+\">someText</option>");

example link : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_value
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:Seems you have to give some text to display as caption in the <option> tag while value attribute would be sending the given value to server. Try this

out.println(" <option value=\"+rs.getString(\"NO\")+\">someText</option>");

example link : http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_value



text is being displayed in drop down box many times but database values are not being displayed
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Actually <option value="somtext"> won't be displayed and caption only does, this is due to hiding the actual value from the displaying one. If you want to check you can see that via page source of your web browser.
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

But if you want to display the actual content as you read out from DB, then just write as follows.
out.println(" <option value=\"+rs.getString(\"NO\")+\">rs.getString(\"NO\")</option>");
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:Actually <option value="somtext"> won't be displayed and caption only does, this is due to hiding the actual value from the displaying one. If you want to check you can see that via page source of your web browser.


yeah i have done this values are being displayed in page source but what should i do to display database values in drop down box then.
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Read my previous post.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
archana tiwari wrote:
Kumaravadivel Subramani wrote:Actually <option value="somtext"> won't be displayed and caption only does, this is due to hiding the actual value from the displaying one. If you want to check you can see that via page source of your web browser.


yeah i have done this values are being displayed in page source but what should i do to display database values in drop down box then.


but doing this we only get same text not the database values.
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

I've posted another after that saying as follows,

out.println(" <option value=\"+rs.getString(\"NO\")+\">rs.getString(\"NO\")</option>");
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:I've posted another after that saying as follows,

out.println(" <option value=\"+rs.getString(\"NO\")+\">rs.getString(\"NO\")</option>");


but its not working ........same value is getting printed.....i want database values
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
archana tiwari wrote:
Kumaravadivel Subramani wrote:I've posted another after that saying as follows,

out.println(" <option value=\"+rs.getString(\"NO\")+\">rs.getString(\"NO\")</option>");


but its not working ........same value is getting printed.....i want database values


please tell me the solution
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Have you tried this code as Eshwin Sukhdeve said? In the result set have you got anything from DB? If you struck with DB value retrieval more example available in net. Check whether result set having value or not then try to display the value.
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Kumaravadivel Subramani wrote:Have you tried this code as Eshwin Sukhdeve said? In the result set have you got anything from DB? If you struck with DB value retrieval more example available in net. Check whether result set having value or not then try to display the value.



yes i have tried this code....but does not work
archana tiwari
Ranch Hand

Joined: Mar 15, 2012
Posts: 44
Punit Jain wrote:please use code tags.
to display calendar you can use java script.
have a google search for javascript calendar.

Hope this helps.


I am using eclipse for pdf.java program to display the calendar but no image is being displayed. there may be an error related to path of image file (.png).How to give path of png file in eclipse?
i am using java script for calendar.....
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: calendar