Vanessa Danin

Ranch Hand
+ Follow
since Oct 04, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vanessa Danin

Joe, your response was certainly not ignorant! As Bear mentioned websockets are not supported in older browsers and is only supported in the current version of IE. My particular application is intranet based and we can control which browsers are run so web sockets are suited to our environment.
8 years ago
Haytham, you may want to consider websockets. A websocket is basically a persistent connection between the client browser and server over a single TCP socket. So the client starts the connection and then, whenever the server has something it wishes to broadcast (e.g. updated data), it simply uses the connection to write updates to the client (e.g. as a text message or JSON String etc). That is, the server is able to send data to the client without any further client requests. I use Dojo on the client and Tomcat's websocket implementation on the server to do this in one of my applications.

You may find some of the links below helpful. The first one explains the concept of websockets and the other two show how to use Tomcat to implement websockets:
http://www.infoq.com/news/2008/12/websockets-vs-comet-ajax/
http://www.tomcatexpert.com/blog/2012/05/01/how-apache-tomcat-implemented-websocket
http://muha.net/blog/8/
8 years ago
The problem is that the prepared statements which set parameters for the phoneInsert, emailInsert and anniversaryInsert sql Strings are setting three parameters and yet the query Strings only declare two parameter placeholders. For example, you have declared String phoneInsert = "insert into phone(work_phone, home_phone) values(?,?)" which has two parameter placeholders (?,?). However, you then try to set three parameters (two Strings and one int) by coding the following:
ps.setString(1, phone.getWorkPhone());
ps.setString(2, phone.getHomePhone());
ps.setInt(3, i);
Mandar, you should not be putting anything in Netbeans build folder. This is for Netbeans' output based on the files you create in the src and web folders. In the clean and build process, the contents of the build folder are cleared before being produced from the web, src and other folders. In other words, you can create files or folders underneath the YourApplication/web/WEB-INF folder (an input folder), but not the YourApplication/build/web/WEB-INF folder (an output folder).
Obviously the request variable's value is null since it has not been set to anything. Actions in Struts2 are not servlets.

In order to access the servlet request, your action needs to implement the RequestAware interface. Please refer to the following API documentation: http://struts.apache.org/2.1.2/struts2-core/apidocs/org/apache/struts2/interceptor/RequestAware.html

In order to implement this interface:
1) Your action class must declare that it implements the interface
2) Include the setter method (and optionally the getter) in your class:
public void setRequest(Map request) {
this.request = request;
}

public Map getRequest() {
return request;
}
3) Declare an instance request variable of type Map

Since the request is a Map, you use Map's put method to set request attributes.
8 years ago
Joe, what happens if you use the non-parameterised version of executeQuery as defined for PreparedStatement, instead of using the inherited version of the executeQuery method from Statement?
That is, what happens if you use:
ResultSet rs = gpsaPrepStmt.executeQuery();
Instead of:
ResultSet rs = gpsaPrepStmt.executeQuery(queryString);

Also, your third query string is incorrect as the question marks in queryString should not have quotes around them.
I would suggest you use an ajax framework like Dojo or jQuery. Although I use plain Dojo in my Struts web applications to implement ajax, you may prefer to use jQuery since Struts provides a jQuery plugin that allows you to use Struts tags to provide ajax functionality. Please see the following link for more general info: http://struts.apache.org/2.3.1/docs/ajax.html
8 years ago
Firstly, as mentioned by Raj, ensure the driver jar (e.g. sqljdbc4.jar) is in your WEB-INF lib folder.
Then you need to refer to it correctly. I don't think that "My Computer" is synonymous with the hostname of your computer. In your URL, rather use localhost if the application and driver are installed on the same machine.
e.g. jdbc:sqlserver://localhost:1433;databaseName=MyDB

I would also recommend using Datasource rather than DriverManager to connect to the database.
Your web.xml file would need to include:
<context-param>
<description>SQL Server db connection value</description>
<param-name>dbSqlSrv</param-name>
<param-value>java:comp/env/jdbc/myChosenReference</param-value>
</context-param>
The param name above is obviously available to the ServletContext by it's getInitParameter method.
And you should have a context resource reference (e.g. in a context.xml file in your META-INF folder) which looks like this:
<Resource auth="Container" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver" name="jdbc/myChosenReference" password="myPassword" type="javax.sql.DataSource" url="jdbc:sqlserver://localhost:1433;databaseName=MyDB" username="myName"/>

Importantly, don't forget to ensure port 1433 is open for SQL Server
8 years ago
It looks like Vijaya is using Struts 1. Vijaya, two issues I noticed were:
1) The Struts Action class has an execute method defined with these parameters in this order: (ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res). However, your execute method has the ActionForm parameter declared first followed by the ActionMapping parameter.
2) You haven't shown your view using a path mapped to your Action class (i.e. does the jsp you are using to invoke this Action class have the form action value set to helloWorld.do?).
8 years ago
Naresh, I use Tomcat (not Weblogic) as my application server. However, just to rule out the obvious, could this session have expired in accordance with your config. Since you say that you have not invalidated the session anywhere in your application code, is it possible that your session timeout value in your web.xml or weblogic.xml file is set too low?
8 years ago
You are confusing two completely different methods. The boolean isNew() method and the HttpSession getSession(boolean create) methods are two different methods in two different interfaces.

As quoted from the API documentation, the isNew() method in the HttpSession interface:

Returns: true if the server has created a session, but the client has not yet joined



And the getSession(boolean create) method in the HttpServletRequest interface:

Returns: the HttpSession associated with this request or null if create is false and the request has no valid session



Is it clearer for you now?
9 years ago
Yogesh, I have absolutely no idea what makes you think that I said that that request.getSession(false) will not return null even if a session does not already exist. Where did I say that??
9 years ago
In other words, the client was not providing the session identifier in requests (e.g. by blocking cookies). URL rewriting allows a session to be tracked even if cookies cannot be used, by adding a session identifier to URLs used by the client. So, by enabling URL rewriting you have enabled session tracking. I hope this makes it easier for you to understand.
9 years ago
Yogesh, as per the API documentation, if the isNew() method returns true it means that the client has not yet joined the session (e.g. if cookies are disabled). Therefore, it doesn't mean that the session has just been created.
9 years ago
Pleasure Teddy! No, Dojo is definitely not deprecated. The Struts Dojo plugin was deprecated. In other words, you should not use Struts tags to make Dojo Ajax calls but using plain Dojo (as I have done in my example) is perfectly fine.
9 years ago