jordan ryan

Ranch Hand
+ Follow
since Oct 31, 2012
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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by jordan ryan

Paul Clapham wrote:The documentation says:

The preferred way to specify the default initialization file is through the log4j.configuration system property.



It goes on to say that once you have specified "log4j.configuration=log4j.xml", you should put log4j.xml somewhere in the classpath, just as you formerly did with log4j.properties.



Hey Paul I understand this and I'm fine with that, my issue is I have to restart the server if I make changes to my log4j.xml. The only way I have found to work around it at the moment is to put this configuration in my code. I was wondering would something like log4jConfigListener, work and how would I implement this ? I'm currently not running log4j2 would this make a difference?
So I have logging working with my log4j.xml. The issue I have is, because ive moved over from .properties to .xml I need to add a few lines in to everything that has a logger.


Is there any way I can do the configuration without having to add these lines of code ? I tried moving the xml to the src folder and instead of giving me the warning bellow it logged nothing.

_______________________________________________________________________________
log4j:WARN No appenders could be found for logger (ProjectName).
log4j:WARN Please initialize the log4j system properly.
_______________________________________________________________________________


At the moment it works fine using the code above, but when I go to implement it in to my real application, it will take forever to add these 2 lines of code. I wondered if theres a way to have it configure the xml automatically?
Solved the Issue, moved the DTD locally and worked fine, my bad silly mistake.
Hey Guys I completed an application and thought it was working fine, But I realised I didnt have a DOCTYPE in my xml, Now once I've added the DOCTYPE the application will now no longer run it gets a time out error I believe Below is my code. If anyone could point me in the right direction that would be great. I'm pretty sure its because I cant use a dom parser for this kind of xml but I'm struggling to find a correct way to do it, when I remover the doctype from the code it works fine so I know its that line int he xml in which my application is not running for.






Error

Bear Bibeault wrote:Your should be using the EL and JSTL in the JSP, not obsolete scriptlets.

In which case, the reference tot he variable would simply be ${test}



Thanks :) I Have it working now but I'm not sure if I did what you meant. This is the code I used is this best practise? I used JSTL like you said I was looking at it but took me a while to understand.

4 years ago
JSP

K. Tsang wrote:Is the "session" attribute enabled in the jsp?

Why is the request dispatcher pointing to a local file?



I dont think I have enabled the attribute in JSP and i'm doing this locally and this was just an example of where the JSP file was, is this wrong to have this as the JSP location?

As you will see my codes quite messy at the moment But I want to get the functionality working and then tidy it all up, the final bit im trying to do is read values from a XML and display these on the JSP. So I'm trying to work out how to send information from the servlet to JSP. I'm not sure if im on the right track at what im looking at or if im looking in completely the wrong place. But at the moment the JSP is not getting anything.

This is my actuall code so far.


4 years ago
JSP
I'm trying to work out how to get a string from a servlet in to the JSP, The code I thought would work was as follows.



This is returning null any help or a link for a few examples would be great. I have tried a few examples and followed a few tutorials but I keep getting null or nullpointexceptions. Any help would be great.
4 years ago
JSP
Yer I kind of gather this and was having problems I now have the code I need, But I'm pretty sure I am over complecating it and not using best practise If I could get some help that would be great my issue is the current lines shouldn't really be there and instead of (1) it should find the one I'm looking for (the one which has text Content which equals file).

So thats the first bit in which I know can be changed but im a bit unsure how to do it, I'm then really doing to many ifs and else ifs and im pretty sure theres an easier way of doing this if anyone can help me or knows something I should look at in which will be an easier more efficient way please let me know.
4 years ago
So I am trying to read in my log4j.xml, edit some of the values then save it again. I am having some issues actually reading the xml because of the params etc.
Could anyone help me I know how to read a normal xml in with getNodeName and getElementsByTagName But this doesnt seem to work as the XML format is a bit more complicated.

this is my XML


This is the java code. It doesnt work atall, it isnt realising the tag name. When I put appender in it goes a step further but obviously thats not what I want. I want to be able to read it with the names I havew given.

4 years ago
Had some luck this morning, Finally got it working . Theres a few things I want to change but I'm not sure how. Firstly I am using radio buttons as post doesnt support dropdown or so thats what it seems, so I would like to find an alternative to use a list instead of radio buttons. Then I want to create another servlet in which this list is read from the servlet. any help would be great I have attached my code soo far.


JSP PAGE:

Paul Clapham wrote:Hopefully you get the idea now, but just in case it isn't quite clear yet, here's the most desirable way to handle things in the simplest situations:

1. Browser sends request to servlet.

2. Servlet processes request, checks validity of inputs, updates databases, puts relevant data into request scope, forwards to JSP.

3. JSP produces HTML (for the browser) including formatted version of relevant data which it found in request scope.

It's tempting to think of what the user sees in the browser after step 3 as "the JSP" but don't do that. Otherwise you find yourself saying things like "the JSP calls the servlet" and that isn't what happens at all.

(Also all of this has nothing to do with XML so I'm going to copy it into a more relevant forum.)



Yes sorry about saying xml I originally thought I need to get the config file in to xml format but apparantly that is not the case and it supports reading in java.

Mark E Hansen wrote:Sure: http://www.lmgtfy.com/?q=servlet+jsp+tutorial

When the user changes the value, you're going to want to go back to the Servlet and let it handle the update of the data. It should then respond with a new page which will show the user the result of the update (perhaps it will be the same page, showing the same data with just the addition of a message at the top which says that the update was successful).

Again, have a look at the Servlet/JSP tutorials - they will help you get the hang of this Model/View/Controller design pattern and it will me much easier to then understand where you need to do which parts.

Good luck.



HAHA Nice link ;). Unfortunately I have searched that and looked at all the pages on there already and I cant really get my head round that. I have managed to create a Form with a submit button but all that I really did was: when the button is clicked it starts the servlet. So I guess im kind of on the right track linking the JSP to servlet just need to try and find out how to use them properly.

Thanks and i'll try and go through them again see if I can work my head round it.

Mark E Hansen wrote:You're on the right track, except that you're not using a JSP page - instead you're having the Servlet emit the HTML directly. You might find it easier to use a JSP page. There are lots of easy-to-follow Servlet/JSP tutorials available so just Google that and follow one or two. You'll quickly get the idea. As far as generating the page the way you are, just mock up an HTML page and make it work the way you want, then adjust your Servlet to generate that.

The tutorials will really help because they will show you how to wire the Servlet to the JSP (or the JSP to the Servlet - depending on how you look at it).



Thanks for the reply again, I have actually done a few things you have said in regards to I have 2 seperate bits of code now. I'm struggling trying to find a good tutorial on how to wire them. I think my google skills are getting terrible. Could you possibly link me to something you think may help.

I now need to get the JSP dropdown box to populated from the servlet, once I know how to wire them I think this should be simple and just move over the while{ }. once thats done I then need to use the selected text from the JSP to update the correct fields. I have managed to work out how to get the selected drop down and get the text from the text area. So also I don't think this will be too complicated. I just need to work out how to wire the servlet to the JSP.
This is the current code I have for the servlet:


JSP Code:

Mark E Hansen wrote:It's hard sometimes to see the relationship between the JSP page and the Servlet. Think of it this way - the Servlet is the place where the application logic happens. The JSP page is just the View where the user is shown the result of the Servlet doing its action(s) and can provide input/actions.

Think about the servlet as the initial point - where your web application user goes first. Your servlet can detect that the user hasn't seen the JSP page yet, so it does a forward (or whatever you want) to the JSP page - providing any data the JSP page will need (like, for example, the values that should appear in the drop down control).

You can include an Edit button on the JSP page so the user can select an entry in the drop down control and then click on Edit. What happens then? What if the Edit button actually went back to the servlet?. The servlet knows where the application is based on the parameters passed when the edit button was clicked, so it can do a forward to the "edit" JSP page with whatever information that page needs to allow the user to edit the value. When the user clicks on the Submit button on the edit page, it goes back to the servlet ...

I hope you can see where I'm going

Sounds like a fun challenge. Good luck!



Hey thanks for the reply this is kind of what I figured.

I'm getting a bit confused though and at the moment I'm kind of writing everything in the Servlet ( its getting really mixed up).

This is the code I have at the moment it collects all the details from the config file and then displays them in a dropdown menu. I really obviously want the dropdown menu in the JSP but I cant really work out how to do this.

I guess whats next is to get the dropdown box in JSP, Once thats done I need to write some code which says if X is selected display properties.getProperty(x); Which I dont think is too hard I just dont know how to get the logic for which item is selected. thanks for the help so far and any more help you guys can give this forum is great.
This is my current Servlet code.

Hey guys had a lot of help from this site, its really great.

I'm currently quite new to java and servlets, but I have an assignment where I need to creat a JSP which invokes a servlet which picks up an xml file read all the nodes etc and then you can pick the node from a drop down list and modify the element I think ive said this correct.

Lets say for example my XML was.



Then I would want a drop down box to be populated with RegistrationNo, StudentID, Name and Fname. Then once I click on that I want it to show the current value lets say for example I picked StudentID, it would show next to it : 1110708048 but then I would like there to be a text box in which I can enter a new one and submit it.

I know how to read xml in to java and modify it etc. Its more the reading the things in to the drop down box etc.