Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Steve Schooler

Greenhorn
+ Follow
since Jan 25, 2005
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 Steve Schooler

Website1 (et al) redirects to Website2 for login, granting session authorization through cookie (presumably). GetRight (download manager) unable to send cookie back correctly. I've had trouble internet-researching getting/sending cookie (or http re-direction) from java stand-alone app. Are there internet resources on this? Since this is a client side task, does this mean it is not a sub-topic of J2EE?

Afraid that even if I defeat Website1, my stand-alone app won't be generic against websites that try to discourage automated downloads? Comments? Anyway, I am able to use Firefox' tabbed browsing to login then invoke self-written/signed applet to automate Website1 downloads, and suspect that this will work generically.

However I'd prefer to not re-invent the wheel (code my own download mgr). Can MyApplet.getRuntime().exec("Getright.Exe") (et al) invoke GetRight as a Windows XP (rather than Dos) application? Assuming so, can this invocation allow GetRight to (somehow) "inherit" the session authorization that MyApplet receives as a Firefox tab?

Assuming GetRight invocation unworkable, are there http-methods analogous to File.list(), File.isDirectory() that can be used against a website that offers no FTP access? Assuming not, are there specific java methods, coding samples, or 3rd party freeware-packages that facilitate "scraping" html-s for links (as GetRight's Browse feature does)?

Somewhat off topic : instead of launching GetRight (et al) from the applet, can GetRight (or other html scraping download manager) be launched (with "session inheritance") from Firefox?
14 years ago
Is this the right sub-forum of Java Ranch for this post??

Trying to create java application that will download a file from a website (e.g. www.website1.com). Following excerpt generally works ok.



Unfortunately, www.website1.com redirects to www.website2.com, so huc.getResponseCode() <above> returns 302 rather than 0. I tried inserting



but still get 302 rather than 0. How do I supply my UserID/Passwd to handle the redirect?

More generally, I'd like to not have to supply the UserId/Passwd with each GET request. Instead, I want to (somehow) login to website1 or website2 at the start of the app (only). Is this doable?

As a last resort, could I create an applet to download the file. From Firefox, if I login to website1 (thru website2), then any other "tabs" in that Firefox session are "authorized". Any reason why this approach won't work?

Request insights, coding samples, website references...
Thanks for your interest. I am assuming that the current working directory is the directory that contains runme.jar. If you think this assumption may lead to trouble, please tell me. Regardless of whether it is or is not, I'm using "." to specify the path needed to find suncertify.properties. If you think this may lead to trouble, please tell me.

When I posted this topic, I intended that if suncertify.properties was missing from the directory that contains runme.jar, that the program would automatically create a new version of suncertify.properties (with default values) in this directory. My intent was to demonstrate that I was handling the situation where the user had inadvertantly lost or corrupted the file. Naturally, I intended to place corresponding entries in choices.txt and userguide.txt.

I have since changed my mind. I've tentatively decided to:
  • Include an additional copy, suncertify.backup in this same directory.
  • Have property-file-corruption or property-file-missing situations trigger a pop-up message that refers the user to a specific area of the userguide.txt file and then immediately System.exit(1) et al.
  • Mention in choices.txt that both the client and server (gui) Help menu items provide direct access to the user guide.
  • Also mention in choices.txt that it is assumed that the user has indirect access to this guide via a text editor.



  • I welcome your reaction to the above + the corresponding userguide.txt entry (below). I don't want to anger the evaluator with my arrogance.

    Want to verify that I'm interpreting the instructions correctly. To avoid auto failure, I welcome criticism. I upload a jar file named <anyname>.jar, whose contents are:

  • <root>
  • <root>\META-INF\MANIFEST.MF
  • <root>\runme.jar {nested jar file}
  • <root>\db-1x3.db {original unchanged database file}
  • <root>\suncertify.properties {properties file}
  • <root>\code\<package1_name>\<source code in package1_name>
  • <root>\code\<package2_name>\<source code in package2_name>
  • ...
  • <root>\version.txt
  • <root>\docs\instructions.html
  • <root>\docs\choices.txt
  • <root>\docs\userguide.txt {et al}
  • <root>\docs\javadoc\<javadoc generated html files>


  • The contents of runme.jar are:

  • <root>
  • <root>\META-INF\MANIFEST.MF
  • <root>\<package1_name>\<class files in package1_name>
  • <root>\<package2_name>\<class files in package2_name>
  • ...


  • Decisions:
  • place db-1x3.db and suncertify.properties in same directory
  • suncertify.properties is NOT contained in runme.jar
  • app will allow db-1x3.db to be re-located and will provide JFileChooser to access it in "server" or "alone" mode
  • app will insist that suncertify.properties NOT be relocated.
  • if properties file not found by app (searching in current directory), it will be regenerated with default values.


  • Request corrections.
    No other way to specify pre-formatting. Some forums allow [pre] ... [/pre], but JavaRanch doesn't seem to. Code box soemwhat misleading, but seems preferable to UNcontrolled formatting. Tightly controlled indentation often needed for clarity.
    Plan to be guided by this forum's lock postings, but it would be nice if there was "brain dead" lock testing (which excludes logic walk thru and conforming to standard pattern). Curious what testing others do. I only have access to two machines. Does this mean that I can only simulate two simultaneous clients?

    Since don't yet know JUnit, prefer to avoid it for now, if feasible. Curious if JUnit big help in this specific situation. I've seen (and written) flawed locking code samples that didn't break on testing. This is apparent problem.

    Wonder what industry standard testing strategy is (besides walk thru and checking for typical pattern of while loop[s] and synchronized methods/blocks)?
    15 years ago