File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
*
The moose likes Servlets and the fly likes Help with Servlet Code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Help with Servlet Code" Watch "Help with Servlet Code" New topic
Author

Help with Servlet Code

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
What am I looking at:




I am wanting to determine if these strings are being passed on the query string and if I needed to add a parameter, how to do so.

Thanks,
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18997
    
    8

Yes, in that code "req.getParameter(something)" gets one of the request parameters.

As for how they get into your application, that depends on whether the request was GET or POST (or one of the other more unusual methods). If it's a GET request then the parameters come in as parameters of the URL (probably what you meant by "on the query string") but if it's a POST request then they work somewhat differently.

As for adding a parameter, you can't do that in your servlet. You can only respond to whatever your client has sent. Now if that question was meant to be how to get the client to send another parameter, then it's a question about the client. About which we know nothing.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61792
    
  67

Taking a guess, if you mean these lines:
Then yes, those are request parameters.

They can be set by the query string on a the request URL (in the case of a GET), or by form elements (in the case of a POST).

[Edit: Paul shot first while I was posting! ]


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 421
How can I be sure that the parentid is passing? I have examined DMTemplateLoaderFLReports and it apperas to be passing a "1" as a parameter.

For example,

https://209.173.134.79:7001/DMTemplateLoaderFLReports?sdate=03/16/2010&edate=03/19/2012&caseid=0&homeid=1&parentid=1&userid=100059&mode=APA&documentFileName=1-EmbalmingReport.doc&homeId=<xsl:value-of select="../../Home/Id"/>&transId=NA&dmDocumentId=<xsl:value-of select="../../DMDocumentId"/>

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18997
    
    8

I don't know what that enormous bit of code was supposed to mean. (Please don't post huge code samples, nobody wants to read them.) However in the URL you posted at the beginning, after the XSLT transformation was complete, there would be three URL parameters, namely "homeId", "transId", and "dmDocumentId". Actually I suppose there could be others if the XSLT transformation generated them, but the code doesn't look to me as if it would do that. It's not impossible, though, so the best way to see what parameters are being passed is to look at the actual URL which is generated rather than trying to figure out what the code might produce.
 
Consider Paul's rocket mass heater.
 
subject: Help with Servlet Code