V K Gupta

Ranch Hand
+ Follow
since Aug 07, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by V K Gupta

Hi,

I want to know "Why CSS Generator is not present in Scene Builder like Dreamweaver". I am using the latest Scene Builder from Oracle's site.
Is CSS Generator is present in Scene Builder provided by any other provider.
5 years ago
Hi guys,

I am trying my hands on JavaFX. While using Property and ChangeListener, I am stuck at point that "how a changeListener receives its value". I am writing a code below, kindly tell me how the values are passed to the ChangeListener.

5 years ago
Which event is generated when a scrollbar is update?
***Please I need quick answer for above question *****
6 years ago
Thanks Chang Ag,

I have re-written by program according to Java Conventions.

Second Question ?

I need producer and consumer thread to be synchronized . If producer produce one item then it should notify the consumer thread about it and after the consumer consume the item it should notify the producer to produce again and it should go on.

consumer thread should not miss any produce item by the producer thread.



Hi Friends,

Please help me with the Producer Consumer Problem using Thread in Java. I have written the program for Producer Consumer Problem using Thread but my program is incomplete , so I want that somebody make the correction and addition in my program to make it complete so that i can understand Threads.


class A {
int value;

public void setA(int v) {
value=v;
}

public int getA() {
return value;
}
}

class put implements Runnable {

A obj;

public void run() {
for(int i=1;i<=10;i++) {
System.out.println("putting in A value is " + i );
obj.setA(i);
}
}

put(A ob) {
obj=ob;
}
}


class get implements Runnable {
A obj;

get(A ob) {
obj = ob;
}


public void run() {
while(true) {
System.out.println(obj.getA());
if(obj.getA() == 10)
break;
}
}

}

public class X1 {

public static void main(String arg[]) {
A obj = new A();

put p = new put(obj);
get g = new get(obj);

Thread p1 = new Thread(p);
Thread g2 = new Thread(g);

p1.start();
g2.start();
}
}
Hi,

Queue is an Interface present in java.util.Queue. Queue supports all Collections methods and other methods like
peek() : returns the highest priority queue and do not removes from the queue.
poll() : returns the highest priority queue and removes from the queue
offer(): add elements to the Priority Queue

These 3 methods are present only in Queue Interface. LinkList class also implements Queue Interface.

PriorityQueue : Is added in Java 5, PriorityQueue (PQ) is different from normal queue (FIFO) as PQ maintains the list as Priority IN and Priority OUT, the elements are ordered either in natural ordering or using comparator.


12 years ago
i am having two javabean files dog.java and person.java inside tomcat/webapps/jsp7/web-inf/classes/foo


----------------------------------------------------------
code of dog.java
----------------------------------------------------------
package foo;

public class Dog {
String name;

public void setName(String name) {
this.name = name;
}

public String getName() {
return name;
}
}

---------------------------------------------------------------------------------
code of person.java
-------------------------------------------------------------------------------
package foo;

public class Person {
String name;
Dog dog;

public void setDog(Dog dog) {
this.dog = dog;
}
public void setName(String name) {
this.name = name;
}

public Dog getDog() {
return dog;
}

public String getName() {
return name;
}
}

The problem is : dog.java files compiles very well, but person.java is not able to compile it shows an error : cannot find symbol Dog
12 years ago
but i am not using any package statement in Person class,
than why should i use com.Person

Please explain
12 years ago
JSP
I am trying to create a simple application in which,

1) index.html -> index page takes a name and passes it to servlet

2) control.java (servlet) -> takes the parameter from index.html , and creates a javabean and set that value into the bean and than finally set the bean as a request attribute, and forward the request to result.jsp

3) person.java (java bean) -> person.java is an java bean having property "name" and getter setter method

4) result.jsp -> this jsp files tries to read the bean value using <jsp:useBean> and <jsp:getPropert> tags.

My application runs perfectly upto servlet and servlet also passes the control to jsp. But in result.jsp a error comes given below.

Note : control.class and Person.class file are stored inside web-inf/classes


An error occurred at line: 13 in the jsp file: /result.jsp
Person cannot be resolved to a type
10: Person is <% //Person p = (Person) request.getAttribute("person");
11: //out.println(p.getName()); %>
12:
13: <jsp:useBean id="person" class="Person" scope="request" />
14: <jsp:getProperty name="person" property="name"/>
15: </body>
16: </html>

-----------------------------------------------------------------------------------------------------------------------------------------

code of all the 5 files is given below

--------------------------------------------------------------------
index.html
------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Index</title>
</head>

<body>

<form id="form1" name="form1" method="post" action="control2.do">


<label>Name
<input type="text" name="name" />
</label>



<label>
<input type="submit" name="Submit" value="Submit" />
</label>


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

----------------------------------------------------------------------
web.xml
-----------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>



<servlet>
<servlet-name>jsp3</servlet-name>
<servlet-class>Control</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>jsp3</servlet-name>
<url-pattern>/control2.do</url-pattern>
</servlet-mapping>

</web-app>

---------------------------------------------------------------------------------------
person.java
-------------------------------------------------------------------------------------
public class Person {
String name;

public void setName(String name) {
name = this.name;
}

public String getName() {
return name;
}
}

------------------------------------------------------------
control.java (servlet)
-------------------------------------------------------------
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;


public class Control extends HttpServlet {
public void doPost (HttpServletRequest request,HttpServletResponse response)
throws IOException, ServletException {

Person p = new Person();
p.setName(request.getParameter("name"));
request.setAttribute("person",p);

RequestDispatcher view = request.getRequestDispatcher("result.jsp");
view.forward(request,response);
}
}

-------------------------------------------------------------------------------
result.jsp
------------------------------------------------------------------------------------
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Result JSP</title>
</head>

<body>
Person is <% //Person p = (Person) request.getAttribute("person");
//out.println(p.getName()); %>

<jsp:useBean id="person" class="Person" scope="request" />
<jsp:getProperty name="person" property="name"/>
</body>
</html>
12 years ago
JSP
Hi,

Can anybody tell me, how to create submenus, horizontally and vertically. Any built in JS, prototypes that I can use on my website.

Or how it can be self build in JS. (Any link to tutorial or book)
I have cleared SCJP exam, I want to use SCJP logo on my visting card, from where I can get the logo
Hi,

I am trying to run Example from Head first Servlets & JSP given on page no 30 (e.g servlet which shows the time)

But as I run the example on IE, i get an error like this

HTTP Status 404 - /ch1/Serv1

--------------------------------------------------------------------------------

type Status report

message /ch1/Serv1

description The requested resource (/ch1/Serv1) is not available.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18




Contents of web.xml are
<?xml version="1.0" encoding="iso-8859-1" ?>
- <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
- <servlet>
<servlet-name>Chapter1 Servlet</servlet-name>
<servlet-class>Ch1Servlet</servlet-class>
</servlet>
- <servlet-mapping>
<servlet-name>Chapter1 Servlet</servlet-name>
<url-pattern>/Serv1</url-pattern>
</servlet-mapping>
</web-app>



contetns of Ch1Servlet.java are
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Ch1Servlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
PrintWriter out = response.getWriter();
java.util.Date today = new java.util.Date();

out.println("<html>" +
"<body>" +
"<h1 align=center>Chapter 1</h1>" +
"
" + today + "</body>" + "</html>");
}
}


Please tell me where I am making an mistake
Is it possible to remove .jsp extension from jsp page in address bar of IE. For example I had the store the file data.jsp and when it is accesed in internet explorer it is shown as http://localhost/test/data.jsp.

But I want to show like this : http://localhost/test/data
12 years ago
JSP