g forte

Greenhorn
+ Follow
since Aug 28, 2003
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 g forte

Sorry, Included.
Thanks.
14 years ago
JSP
Bear,
thanks for the reply.
I am using the NTLM servlet to pull the authenticated username from the browser.
So for instance if I access the Servlet it prints out mydomain/gforte.
I was trying to "include" the Servlet in my jsp and "grab" that string(mydomain/gforte).

I could easily do this by accessing the Servlet first and then redirect to my jsp and pass this as a POST parameter OR set a session in the servlet and then redirect, but I was trying to keep it modular so that other apps could use it.

How else could I access a Variable called authenticatedUser (that resides in the Servlet) from my jsp without a redirect from the servlet?

Thanks for any tips!
[ March 14, 2007: Message edited by: g forte ]
14 years ago
JSP
Pseudo code:

//Servlet
String theString = "Servlet's output String";
PrintWriter out = response.getWriter();
out.print(theString);


//JSP
<%
String thestringFromServlet = Servlet's output String;
%>





Is this possible?
TIA!
14 years ago
JSP
Sounds good, unless you need to offer this file(the one just uploaded) to other users to download. In that case, I would change the mime type to
response.setContentType("application/x-download");
Which would force the download dialog as opposed to opening it up in the browser.
HTH
If the user is authenticated to a domain you may be able to grab userName/domain using this Servlet. I have had some success in the past with this.
http://www.jguru.com/faq/view.jsp?EID=1045412

HTH!
14 years ago
I think you need an id for your form fields.


Also, did you grab the 2 required jars(fileupload.jar and the io jar)?
HTH!
[ February 23, 2007: Message edited by: g forte ]
Hello all,
I have an application that accepts an url as a querystring parameter.

http://mapapp/mapit?zoomlevel=10&url=http://myserver/xmlFileName.xml

The url parameter is a URL to a file.
I want to, instead , pass a Servlet output stream as the url parameter.

http://myapp/mapit?zoomlevel=10&url=http://myserver/MyServlet

I can do this if I hard code the PrintWriter output stream with a rss feed String.

What I need to do is to be able to dynamically construct the rss feed within the Servlet by passing parameters to it.

Now you are probably saying: Use the POST method and embed parameters in hidden form fields. I thought of that but dont think it is possible.

Here is why...

I have a jsp with a map div and also a links div. Each link needs to be a link to each individual rss feed, that when clicked, populates the mapapp with the rss feed. I have no control over the map app below: http://mapapp/mapit?zoomlevel=10&url=http://myserver/xmlFileName.xml

I wanted to do the following:

Basically calling my servlet as the FileInput and constructing the PrintWriter stream on the fly.
Now the url above crashes the mapping app when I append a Servlet querystring.

So is there a way to do the following:
Create a link to the mapping app that contains the url to my servlet that gets passed the rss feed parameters to construct the feed that is passed to the mapping app? Basically the link causes the mapping app to import a rss feed that it knows nothing about beforehand.

Does this make sense?

Let me know if it doesnt.
TIA!
14 years ago
Thanks,
not sure I understand you though.
Is it not possible to return an attribute from the listener or is this poor design or both?

Do you have any ideas as to a way to track people when they are in the chat room.

I figured that if I return the getAttribute("userName") and added it to a Application scoped variable (array,List,etc...) I could just print this variable to the page on each subsequent ajax call. Then when the sessionDestroyed method is called I could remove this userName from the variable.
Make sense?

Thanks again.
15 years ago
Not sure as to when the listener is called in relation to the jsp. I have the listener registered in web.xml and I get the System.out results almost exactly when I load the jsp which only contains the following code for testing.


Is there a way to control when the listener is called?

Perhaps this is not the correct design pattern for what I am trying to accomplish....my thoughts were that this would be a way to generate a listing of all users that are logged into a chat room.
Ideas?
Thanks for your input.
15 years ago
Hello all,
I have a HttpSessionListener that works fine.
I can get it to return a active session count and also each session ID.


Now I tried to return a specific attribute by using the following code:


but it returns null.
In my jsp I set it like so


Is this expected bahaviour?
If not, how can I return a listing of all sessions.getAttribute("myAttribute")

TIA!
15 years ago
Hello all,
I am creating a chat application. I use a jsp that connects to a servlets via Ajax. One servlet receives the message that the user typed and processes it(passes to XMPP server among other things) and also Writes to an xml file specific to each pair of users. Another servlet checks and returns the chat message to the user. I also have a Servlet that checks for all users presence. So I have a servlet that Sets chat and one that Gets chat and one that Gets Presence basically. Now I need to set a global type object(I was thinking a List,Array or perhaps a StringBuffer or ??) that will store a.... (lets call it a notification). So when the SetChat servlet is called I can update this global object....and then when the GetPresence servlet is called, I can read this global object for each users name and if it exists, read the xml file with the recently added chat. I need to do this in lieu of iterating through the directory that holds all xml files and determine if the file has changed and if so read it(too much overhead).
I tried this:
I set create a StringBuffer when SetChat servlet is called and append. Each time this SetChat servlet is called I append with new string. This works fine but is only available to SetChat servlet. I tried the RequestDispatcher but I could not get it to work. Returns null...plus I think this is the wrong thing to use.
Any ideas as to what I can use here?
TIA!
15 years ago
Thanks Ernest that did it!!
15 years ago
Actually it compiled with no problem but when I run it I get this error:

Here is my code first:


Here is my error:

java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
\
^
15 years ago
Great That worked!

Thanks Shyam.
15 years ago
Hello all,
I was wondering what the proper syntax for the replaceAll method was if I wanted to replace all instances of \ with /

TIA!
15 years ago