phillip nash

Greenhorn
+ Follow
since Feb 08, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
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 phillip nash

Hello all.

I'm currently developing a system which allows the user to login to perform their activities.
As a requirement, I'm developing a way for the user to reset their password if they forget.
Now, my web service is tied to a database, where it generates a unique token (expires after a certain amount of time)
and emails this to the user, for them to click and reset their password etc. The URL (with the unique token) they click is a JSP page, where I have
two fields and a "Submit" button.

Something like this which gets email to the user http://localhost:8080/resetPassword.jsp?token=UNIQUE_TOKEN

As a security measure, I have two seperate JSP pages. One which is public accessible (contains the unique token, button, and two text fields),
and one that is inside the WEB-INF folder. I can forward the token parameter from the public accessible JSP to the JSP page inside the WEB-INF folder.


Is there a way that I can grab all of the parameters from the text fields on the JSP page and token, to send this off to my webservice.

Thanks
5 years ago
JSP

Bear Bibeault wrote:Yes, all java code and operations should be in Java classes, not in JSP.

If you are a newcomer to JSP be aware that putting Java code in a JSP is an obsolete practice from over 12 years ago that somehow will not die a deserved death. Any resource you are using that advocates putting Java code in a JSP should be ditched for a more modern reference that emphasizes the use of the EL (Expression Language) and JSTL (JSP Standard Tag Library).

The sort of thing you are talking about most certainly does not belong in a JSP, which should only be used for creating the view.

I'd also recommend the following articles:

  • The Secret Life of JSPs
  • The Front Man


  • The first explains what JSP is all about; the second, how to properly structure a modern Java web app.



    BTW that second link is a godsend!
    5 years ago
    JSP

    Bear Bibeault wrote:Yes, all java code and operations should be in Java classes, not in JSP.

    If you are a newcomer to JSP be aware that putting Java code in a JSP is an obsolete practice from over 12 years ago that somehow will not die a deserved death. Any resource you are using that advocates putting Java code in a JSP should be ditched for a more modern reference that emphasizes the use of the EL (Expression Language) and JSTL (JSP Standard Tag Library).

    The sort of thing you are talking about most certainly does not belong in a JSP, which should only be used for creating the view.

    I'd also recommend the following articles:

  • The Secret Life of JSPs
  • The Front Man


  • The first explains what JSP is all about; the second, how to properly structure a modern Java web app.



    Fantastic!!!

    Thanks for your help
    5 years ago
    JSP

    Bear Bibeault wrote:A JSP is intended to render a view, not perform operations. Why aren't you simply sending the web service request from a controller? It'd be a lot more appropriate and a lot less hassle.



    Thanks for your reply!

    I only have a bit of experience with JSP. When you say controller, do you mean having a dedicated java servlet to process and forward the requests to the other parts of the system?

    5 years ago
    JSP
    Hello all.

    I'm working on a project (my first job since leaving university/college) where I need a html page to communicate with a JSP for processing login information.
    Now, I'm looking into processing this using the SOAP protocol, due to its interoperability functionality. I need this JSP page to send SOAP requests to a web service for processing and storing.
    Is it possible for to use SOAP and JSP for this at all? I haven't found much information about this neither. If somebody could point me in the right direction, that would be fantastic.

    Thanks
    5 years ago
    JSP

    Oli Wurster wrote:Have you debugged the servlet? Is there a new GET request every 1 second? I think that it could be a network or client problem. The auto refresher probably is some kind of client script that refreshes the page every interval. It could also be a problem on the auto refresher.



    Thanks for the reply. There's a get request every second. This is running on my localhost machine (until deployment).
    Do you think there can be a performance hit when running GlassFish on a localhost machine? Rather than a dedicated
    server? Personally, I think its because my dev-machine. Its kinda slow and crap to run GlassFish
    7 years ago
    Hello. I'm having trouble with obtaining the current second from my servlet.



    As you can see, the code looks totally fine. But, actually, the problem is when I'm running it in my browser (Chrome) the seconds are correct. However, at times it actually skips a second, which is messing up parts of my application.
    When I use System.nanoSeconds() I've noticed every time I get the current time (using an auto refresher - refresh every second) a few of the milli digits are actually increasing every seconds the auto refresh kicks in. Eventually, the servlet skips a second.

    Any tips please? The code you see is the only code that's actually running.
    7 years ago
    The class in which I want to refer to deals with launching 4 threads to communicate with these sensor boxes I'm playing around with. If I restart my webservice (not GlassFish) I get various errors relating to my thread pool. So, in order to sort this out, when I restart my webservice I need a way to shutdown the thread pool so it can restart again when I launch the service.
    7 years ago

    Bear Bibeault wrote:

    phillip nash wrote:Basically when the servlet shuts down and executes contextDestroyed().


    As has already been pointed out, servlets do not "shut down". Are you asking about when the web app is being shut down? Until you can accurately define what you are trying to do, help will be difficult to offer.



    Yes. Sorry. When I shutdown GlassFish I need to call a method that's in another class to shutdown a thread pool.
    I don't know if I can refer to the class within contextDestroyed() that contains the method I need to call. I currently looking at getServletContext().getAttribute() to see if I can refer to the class
    which contains the code for shutting down the thread pool.
    7 years ago
    However, I could move some of my objects into the class which implements ServletContextListener, but this means in my servlet code I'll need to refer back to them in order to use their
    methods. Doing it this way I can easily shut down my thread pool. I'm not too sure if this is even possible.
    7 years ago

    E Armitage wrote:By servlet shuts down do you mean container shutdown? If so call the method in the



    Basically when the servlet shuts down and executes contextDestroyed(). Within that method I'd like to refer to an object that was created when my servlet first started up.
    I tried to implement ServletContextListener within my servlet class, but I was getting errors (I think it's because I'm creating a new servlet object).
    7 years ago
    Hi all.

    I've got a ServletContextListener set up and working correctly. When the servlet shuts down I need it to call a method within another class to shut down a thread pool.
    Is it possible for a ServletContextListener to do this?

    Thanks
    7 years ago
    Sorted it. Instead of importing the .jar as an archive, I went an actually imported it as a file.

    I hope this'll help others.
    7 years ago
    Thanks for the reply. Am I correct in that when I right click on WEB-INF folder > Import > Archive File = SNMP4J this should import this into the project? I've just done this and I'm still getting
    the same error. I'm really a beginner when messing around with the build paths etc.

    Thanks for your time and help.
    7 years ago
    Hello all.

    I'm working on developing a web service and I need to use SNMP4J to do what I need to do. When I run the application as an application it works fine, but when I create a servlet
    project, add SNMP4J to my library folder, and finally compile my application I get this error

    "SEVERE: Class [ org/snmp4j/smi/Address ] not found."

    Is there something I'm missing here?

    Thanks.
    7 years ago