B4J Question Dim In As InputStream = req.InputStream

Discussion in 'B4J Questions' started by schimanski, Jun 19, 2015.

  1. schimanski

    schimanski Well-Known Member Licensed User

    I have a problem with reading paramters in the server-handler. When i call Dim In As InputStream = req.InputStream, i can only read out the paramter "type". The other parameters are only available, when I do not set Dim In As InputStream = req.InputStream.
    Code:
    Sub Handle(req As ServletRequest, resp As ServletResponse)
       
        
    If req.Method <> "POST" Then
            resp.SendError(
    500"Methode wird nicht unterstützt! (nur POST)")
            
    Return
        
    End If
       
        
    'we need to call req.InputStream before calling GetParameter.
        'Otherwise the stream will be read internally (as the parameter might be in the post body).
        Dim In As InputStream = req.InputStream
        
    Dim reqType As String = req.GetParameter("type")
       
        
    Log(req.GetParameter("type"))
        
    log(req.getParamter("absender"))     <----- is emty!
        
        
    If reqType = "" Then
            resp.SendError(
    500"Parameter für den Dateityp wurde nicht übertragen (text oder file)")
            
    Return
        
    End If
        
    Select reqType
            
    Case "status"
                    .............
     
  2. billzhan

    billzhan Active Member Licensed User

    typo: req.getParamter("absender") . GetParameter
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You need to first get the URL parameters and only then get the input stream (see the comment in the code).
     
Loading...