Joseph Erickson

Greenhorn
+ Follow
since May 05, 2006
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 Joseph Erickson

If you're using the Validator, you can use the following validation in your validator.xml


url - validates url format. Has four optional variables (allowallschemes, allow2slashes, nofragments and schemes) which can be used to configure this validator.

  • allowallschemes specifies whether all schemes are allowed. Valid values are true or false (default is false). If this is set to true then the schemes variable is ignored.
  • allow2slashes specifies whether double '/' characters are allowed. Valid values are true or false (default is false).
  • nofragments specifies whether fragements are allowed. Valid values are true or false (default is false - i.e. fragments are allowed).
  • schemes - use to specify a comma separated list of valid schemes. If not specified then the defaults are used which are http, https and ftp.

  • <field property="custUrl" depends="url">
    <arg0 key="customer.url"/>
    </field>

    <field property="custUrl" depends="url">
    <arg0 key="customer.url"/>
    <var>
    <var-name>nofragments</var-name>
    <var-value>true</var-value>
    </var>
    <var>
    <var-name>schemes</var-name>
    <var-value>http,https,telnet,file</var-value>
    </var>
    </field>

    http://struts.apache.org/struts-doc-1.2.4/userGuide/dev_validator.html


    [ May 10, 2006: Message edited by: Joseph Erickson ]
    16 years ago
    You have to check explicitly, from what I understand. One of Struts' features is that you don't have to worry if it was a GET or a POST. It rolls all of that into one execute method.

    You can override doGet and doPost, but that will break the whole Struts framework stuff. Not recommended. I would just do an if on request.getMethod();
    16 years ago
    Should be:

    16 years ago
    You shouldn't be overridding the execute method, or at least you need to call super.execute() when you're done. The execute method of the DispatchAction is what is looking at that parameter and calling your create() method.
    16 years ago
    If you want to know what Action was executed, mapping.getPath() is the way to go. I just wondered why you needed to know.

    There's a lot of good data you can get about how your action was called from the ActionMapping object that gets passed into your execute() method. Might help you with what you're doing.

    http://struts.apache.org/struts-action/struts-core/apidocs/org/apache/struts/config/ActionConfig.html
    16 years ago
    In your servlet, try:



    What you want is probably in the ActionMapping, if this isn't what you were looking for. Since the servlet can actually be mapped to many different Actions, the servlet itself won't know where it came from.

    Why do you need to know the Action the servlet is being called from? Debugging? You probably shouldn't have specific functionality tied to which mapping your servlet is using. I would break these out into specific Action classes if you are.
    16 years ago

    I hope you are not thinking of the HttpSession object! That is created and managed by the servlet container.



    No, I wouldn't store the whole HttpSession, just the vlues I needed.

    Make your own user Serializable "session" to manage persistance in a database and sharing across applications.



    That was my thought too, but I wasn't sure the best way to handle a key for that persisted session. I found out recently that if a user switches from one application to the next, it actually uses the same session id across the applications, even though they get a new HttpSession every time. I could use this key to hold their persisted data and load it in via a Filter when I needed it.

    So, second question. Is it guaranteed, in all J2EE servers, that their sessionid will always be the same across applications? Is this "functionality" I should be relying on?
    16 years ago
    You won't be able to link directly to those images because they aren't in the web server's directory, but you might be able to link that folder into the web server's root document directory on the F drive. In Windows land, this would probably be done by a shortcut. You could make a shortcut of C:\Allimages, call it "images", and drop the shortcut into the Web Server's root document folder. Then the img tag should be <img src="/images/blah.gif" />

    Do you know what the document root folder is for the web server?
    16 years ago
    This is probably a bad example for the real world, but bear with me.

    Let us imagine that I have a data object that I want to be able to store as a serialized object (in an HttpSession or some such). This object will hold String values of firstName and lastName and I want these to be stored when it's serialized because they will be accessed often and it should be quick. But I will also have a picture of the person that I DON'T want stored because it'll be too big and won't be accessed that often. So I can create that class like so:



    If the firstName and lastName values are called after it's deserialized, it will already have the values and not need to do anything special. But if someone wants the picture, I can load it in and return it. If the picture is requested again before it's reserialized, it's already in memory and I can ust return it. If it's serialized though, picture will be set to null and not saved because it's set as transient. That will save space in memory.

    Hopefully that's a good explanation.
    [ May 05, 2006: Message edited by: Joseph Erickson ]
    16 years ago
    We're looking at building a fairly complex, large Servlet application in SAP NetWeaver. I was hoping that we would be able to break out the conceptually related pieces into their own Enterprise Applications. This way we could have a login application seperate from the billing application so that the code is more maintainable and if we needed to update some of the billing code, we wouldn't have to redeploy everything.

    The problem comes in when we want to use session data across the applications for single sign on or just for sharing small amounts of data during the user's visit. I have an idea to store the user's session in a database and load it back in depending on a cookie when they hit a new application, but this relies on cookies and doesn't seem like it would work for URL rewriting.

    Anyone else have ideas on how a shared session object across applications might work?
    16 years ago